To start developing apps with react native, there are two different phases of setup required:
Setting up the npm project
Setting up each target platform (currently only iOS and android are supported)
To make the setup easier and to get started quicker, you can also use the react-native-starter-app as your starting point. To do so, simply clone the repo from:
For messaging support the react-native sdk uses react-native-firebase, specifically its Cloud Messaging Module. To setup the same, follow the steps as outlined on https://rnfirebase.io/docs/v5.x.x/installation/android
NOTE If you are using the starter app as a base template, you can skip the section Install Modules in the link above.
Setting up individual platforms
Since cloud messaging works at a lower level than most apps, setting up the Mitter.io SDK for react native requires further setup on each of the target platforms.
The native-sdk uses rn-fetch-blob for managing file uploads. Performing a link on the project is usually required before being able to use this package:
React native has the exact same usage as other Javascript SDKs apart from the fetching the mitter.io object:
Using the SDK with containerized Mitter.io
If you are using the Mitter.io docker container, you will have to override the API url:
For the <mitter-api-url>, use the following value:
If you're using the cloud hosted solution, you can omit the mitterApiBaseUrl key in the config or explicitly set it to https://api.mitter.io
If you're running it as a docker container set it to http://localhost:<port> where the port is port forwarded by docker for 11902. To find out which port it is, run the following command docker port $(docker ps --filter expose=11901-11903/tcp --format "")
Once you have the mitter object for React Native, you can continue from the Usage and user authorization section in the Javascript reference.
const mitter = Mitter.forReactNative(/* your application-id */)
app.js
import { Mitter } from '@mitter-io/react-native'
const mitter = Mitter.forReactNative({
applicationId: 'fb70ff76-ea33-4bb0-bd59-90853f103202', /* provide your application id here */
mitterApiBaseUrl: '<mitter-api-url>' /* look below for the values */
}, {
onTokenExpire: [] /* Your onTokenExpire functions */
})