Suggestions

close search

Push notification

When your app is disconnected from Stringee Server, it cannot receive real-time updates. Use Stringee Push Notification to keep the app informed about new chat events.

Create the corresponding iOS and Android push projects on Stringee Dashboard. For iOS, upload an APNs authentication key as described in React Native Push Notification.

Get a remote push notification token

  1. iOS

    Request notification permission, then obtain the APNs device token. With React Native Firebase:

    await messaging().requestPermission();
    const token = await messaging().getAPNSToken();
  2. Android

    Obtain the Firebase Cloud Messaging registration token:

    const token = await messaging().getToken();

Listen for token refresh events and register the replacement token with Stringee again.

Register the token with Stringee Server

Register the token after StringeeClient has connected:

await stringeeClient.registerPush(
  token,
  false, // iOS: false for APNs sandbox, true for production.
  false  // iOS: false because chat uses a regular remote notification token.
);

On Android, the last two arguments are ignored. On iOS, use isVoip = false for chat notifications and make isProduction match your APNs environment.

Stringee chat notifications contain a data payload similar to:

{
  "stringeePushNotification": "1.0",
  "type": "CHAT_EVENT",
  "data": {
    "convId": "CONVERSATION_ID",
    "convName": "Conversation name",
    "from": "USER_ID",
    "displayName": "Display name",
    "msgId": "MESSAGE_ID",
    "seq": 2,
    "type": 1,
    "message": {
      "content": "Hello"
    }
  }
}

Unregister the token

When the user signs out, unregister the token before disconnecting:

await stringeeClient.unregisterPush(token);