Skip to content

rettersoft/rbs-ios-sdk

Repository files navigation

RBS

CI Status Version License Platform

Example

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

About RBS

RBS can be used by developers to build event based systems. You should create an RBS account and an RBS project to start.

https://console.rtbs.io

Requirements

You need to have a RTBS projectId.

Installation

Cocoapods

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

pod 'RBS'

Swift Package Manager

You can use swift package manager with following repo url and using main branch:

https://github.com/rettersoft/rbs-ios-sdk

Initialize SDK

Initialize the SDK with your project id created in RBS console.

let rbs = RBS(config: RBSConfig(projectId: "{PROJECT_ID}"))

Authenticate

RBS client's authenticateWithCustomToken method should be used to authenticate a user. If you don't call this method, client will send actions as an anonymous user.

rbs.authenticateWithCustomToken(customToken)

RBS custom tokens can be generated by a RBS service by contacting RBS core service via RBS SDK.

  • A client app sends a request to a RBS service which has permission to generate RBS custom tokens.
  • RBS Service uses RBS SDK on the server side to communicate with RBS Core to generate custom token with user credentials.
  • RBS Core creates a custom token and returns it to the service.
  • The service returns it to the client application.
  • The client application uses RBS SDK authenticateWithCustomToken method to sign in as this user. From that point on any request made by this client, is recognized as this user by all RBS services.

You can sign out with .signout method.

rbs.signOut()

RBS Delegate

You can attach a delegate to RBS client.

rbs.delegate = self

And start receiving authentication state changes.

extension ViewController : RBSClientDelegate {
    func rbsClient(client: RBS, authStatusChanged toStatus: RBSClientAuthStatus) {
        print("RBS authStatusChanged to \(toStatus)")
    }
}

Send Actions

Actions are unique strings to call a service on RBS. Actions have 4 parts separated by dots like below:

{COMPANY}.{SERVICE_ID}.{ACTION_TYPE}.{ACTION_NAME}

Action Type can only be “event” or “request”.

Some examples:

  • rtbs.oms.request.INSERT_ORDER
  • rtbs.oms.request.LIST_MY_ORDERS
  • rtbs.oms.event.ORDER_CREATED
  • rtbs.notification.request.SEND_SMS
  • somecompany.awesomeservice.request.DO_STUFF

You can use .send method to send actions to RBS services. The list of which actions will trigger which services is listed in your RBS project configuration.

rbs.send(action: "rbs.someservice.request.SOME_ACTION",
         data: [
            "key": "value",
         ],
         onSuccess: { result in
            print("Result: \(result)")
         },
         onError: { error in
            print("Error Result: \(error)")
         })

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published