Hosting AE SDK in your React-Native app
React Native component that wraps and loads Anywhere Expert SDK. The React Native component also supplies the same API as the web-sdk.
Installation
Run the following command inside your application directory:
npm install '@npmsoluto/anywhere-expert-rn-sdk'
Usage
Import the component js module:
import { AE_SDK, SDKEvent } from '@npmsoluto/anywhere-expert-rn-sdk';
const APP_KEY = `YOUR_SDK_APPKEY`;
export default function App() {
const sdkApiRef = React.useRef();
return (
<View style={{ flex: 1 }}>
<AE_SDK
registerToEvents={registerToEvents}
appKey={APP_KEY}
onLoad={(err, sdkApi) => sdkApiRef.current = sdkApi}
/>
</View>
);
}
Props
appKey (required)
String representing your AppKey configured for your application.
registerToEvents
List of sdk events to be triggered from within the webview. (see Events)
onLoad
called when the SDK has been initialized. returns error (if exists) and an SDK_API object
Api
The RN component lets you call any API function provided by the original SDK (see documentation).
try{
await sdkApiRef.messagingApi.sendTeamMessage("Hello there!");
console.log("success");
}catch (e){
console.log(e);
}
Events
The RN component lets you register to any SDK event explained in documentation.
Simply specify the event names you are interested in subscribing to and provide that list to the component's props. (see Props)
const SDKEventsRegistration = [
SDKEvent.MESSAGE_RECEIVED,
SDKEvent.MESSAGE_SENT,
SDKEvent.SEND_MESSAGE_FAILED,
SDKEvent.SESSION_CHANGED,
SDKEvent.LOGGED_IN,
SDKEvent.LOGGED_OUT,
SDKEvent.LOGIN_FAILED,
SDKEvent.PROACTIVE_EXPERIENCE_VIEWED,
SDKEvent.TIMELINE_ITEM_SKIPPED
];
const registerToEvents = (emitter) => {
SDKEventsRegistration.map((e) => {
emitter.on(e, (args) => {
// handle event 'e' triggering
});
});
};
Push Notifications
- Share your app bundleId and FCM Server Key with our team so we can set it up on our backend services.
- Call the api function
registerNotificationToken(token,appBundleId)
/registerApnsToken(token,appBundleId)
for Android/iOS respectively.
Example
Full example provided in this repo as rn-sample-app
, containing all phases for using and integrating SDK in your React-Native application.
Known Issues
Currently RN-SDK doesn't support VoIP calls.