Skip to content

rettersoft/rio-ios-sdk

Repository files navigation

Rio - retter.io

CI Status Version License Platform

Example

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

About Rio - retter.io

Rio can be used by developers to build serverless object oriented systems. You should create an retter.io account and an Rio project to start.

https://c.retter.io

Requirements

You need to have a Rio projectId.

Installation

Cocoapods

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

pod 'Rio'

Swift Package Manager

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

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

Initialize SDK

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

let rio = Rio.init(config: RioConfig(projectId: "{PROJECT_ID}"))

Authenticate

Rio 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.

rio.authenticateWithCustomToken(customToken)

You can sign out with .signout method.

rio.signOut()

Rio Delegate

You can attach a delegate to Rio client.

rio.delegate = self

And start receiving authentication state changes.

extension ViewController : RioClientDelegate {
    func rioClient(client: Rio, authStatusChanged toStatus: RioClientAuthStatus) {
        
    }
}

Get a cloud object

rio.getCloudObject(with: RioCloudObjectOptions(classID: "Test")) { object in
    
} onError: { error in
    
}

Call a method on a cloud object

object.call(with: RioCloudObjectOptions(method: "sayHello")) { resp in
    
} onError: { error in
    
}

Listen to realtime updates on cloud objects

object.state?.public.subscribe(onSuccess: { data in
    
}, onError: { err in
    
})

License

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