ZumoKit
class ZumoKit
The entry point of the ZumoKit SDK. Import ZumoKit
module from react-native-zumo-kit package:
import { ZumoKit } from 'react-native-zumo-kit';
Proceed to configure the module by calling init method. Your ZumoKit account manager will provide you with API key. Then, proceed to sign in a user with call to auth method. If sign in is succesful a User instance will be returned, otherwise promise will be rejected with error details. See Handling Errors for details.
Property state contains current SDK state. Register state listner with addStateListener. Unregister listener with removeStateListener.
Properties
state
state: Object
Returns current ZumoKit state object, which implements State interface.
VERSION
VERSION: String
Returns current ZumoKit SDK version.
Methods
init
init(config: Object): void
Configures ZumoKit instance. Your ZumoKit account manager will provide you with API key. See Getting Started for details.
Example
ZumoKit.init({
txServiceUrl: TX_SERVICE_URL,
apiKey: API_KEY
apiRoot: API_ROOT,
myRoot: 'https://www.example.com/',
});
addStateListener
addStateListener(callback: function): void
Attach listener called when there is a change to ZumoKit state.
Example
ZumoKit.addStateListener(function(state) {
// State has changed.
})
auth
auth(token: String, headers: Object): Promise<User>
Authenticate user with ZumoKit. See Getting Started for details.
If sign in is succesful a User instance will be returned, otherwise promise will be rejected with error details. See Handling Errors for details.
Example
try {
await ZumoKit.auth(USER_TOKEN, {
"Optional-Header-1": "example-value"
});
// Authentication was successful!
} catch (error) {
// There was a problem authenticating.
{ type, code, message } = error;
}
removeStateListener
removeStateListener(callback: function): void
Remove state listener. In React Native listener should be removed when a component is unmounted.