Latest 1.0.3
Homepage https://github.com/zetapush/zetapush-swift-services
License MIT
Platforms ios 8.0
Dependencies ZetaPushSwift, Gloss
Authors

Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

ZetaPushSwiftServices must be run with ZetaPushSwift pod.

Installation

ZetaPushSwiftServices is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ZetaPushSwiftServices"

Usage

This repository gives you the auto-generated code to use ZetaPush services. A ZetaPush service as listed in the reference site is a technical service available on ZetaPush’ Cloud. This service can be used in your Swift code.

For each service, we provide:

  • a Publish class with every ZetaPush services verb available as a method
  • a Listener class that you MUST override with every ZetaPush services output available as a method to override
  • every structures needed to call or to receive data from ZetaPush

Please refer to the ZetaPushSwift repository to learn the basics of ZetaPush connection with Swift. We will enhance the basic connection example to use ZetaPushSwiftServices

import UIKit
import ZetaPushSwift
// Import the new Pod
import ZetaPushSwiftServices

// Override the StackListener class
class MyStackListener: StackListener{
    // Override the on_list function
    public override func on_list(_ data: StackListResponse) {
        print("MyStackListener onList", data)
    }
    // Override the on_push function
    public override func on_push(_ data: StackItemAdd) {
        // Here, we will receive all call result to the push verb for my Stack service
        print("MyStackListener onPush", data)
    }
}

class ViewController: UIViewController {

    let zetaPushWeakClient:ZetaPushWeakClient = ZetaPushWeakClient(sandboxId: "YOUR_SANDBOX_ID", weakDeploymentId: "YOUR_WEAK_DEPLOYMENT_ID")

    // declare your service publisher: here, we use a StackPublisher for the Stack Service (https://ref.zpush.io/#it_stack)
    var stackPublisher: StackPublisher?

    // declare my service listener
    var stackListener: MyStackListener?
    override func viewDidLoad() {
        super.viewDidLoad()

        zetaPushWeakClient.onSuccessfulHandshake = onSuccessfulHandshake

        // Create the StackPublisher 
        stackPublisher = StackPublisher(zetaPushWeakClient, deploymentId:"YOUR_STACK_SERVICE_DEPLOYMENT_ID")

        // Create the StackListener
        stackListener = MyStackListener(zetaPushWeakClient, deploymentId:"YOUR_STACK_SERVICE_DEPLOYMENT_ID")

        // Connect to ZetaPush
        zetaPushWeakClient.connect()
    }

    func onSuccessfulHandshake(_ client:ClientHelper){
        // The connection to ZetaPush is a success
        print("ViewController SuccessfulHandshake")
    }

    @IBAction func OnMyFirstTestDown(_ sender: Any) {

        // Create a stackItemAdd object
        let dataStack = ["message":"Hello World"]
        let stackItemAdd = StackItemAdd(json: ["stack": "myGreatStackName", "data": dataStack])

        // Call the push method to call the "push" verb of the stack Service
        stackPublisher?.push(parameter: stackItemAdd!)
    }
}

That’ all! It really easy to call ZetaPush services with predifined Publishers and Listeners

Author

Morvan Mikael, [email protected]

License

ZetaPushSwiftServices is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ZetaPushSwiftServices",
    "version": "1.0.3",
    "summary": "ZetaPushSwiftServices is an auto-generated code of ZetaPush services",
    "description": "ZetaPushSwiftServices is an auto-generated code of ZetaPush services.nIt contains all structures needed to call ZetaPush services and for received responsesnEvery services can be called by a ServiceNamePublisher classnOne must inherit from the ServiceNameListener class and overide the desired method",
    "homepage": "https://github.com/zetapush/zetapush-swift-services",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Morvan Mikael": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zetapush/zetapush-swift-services.git",
        "tag": "1.0.3"
    },
    "social_media_url": "https://twitter.com/zetapush",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ZetaPushSwiftServices/Classes/**/*",
    "dependencies": {
        "ZetaPushSwift": [
            "~> 1.0"
        ],
        "Gloss": [
            "~> 1.2"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This