To run the example project, clone the repo, and run pod install
from the Example directory first.
RBS can be used by developers to build event based systems. You should create an RBS account and an RBS project to start.
You need to have a RTBS projectId.
RTBS is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RBS'
You can use swift package manager with following repo url and using main branch:
https://github.com/rettersoft/rbs-ios-sdk
Initialize the SDK with your project id created in RBS console.
let rbs = RBS(config: RBSConfig(projectId: "{PROJECT_ID}"))
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()
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)")
}
}
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)")
})
RBS is available under the MIT license. See the LICENSE file for more info.