Suggestions

close search

Push notification

When your app becomes disconnected from Stringee server, you can not receive real-time updates. In this case, you use Stringee Push Notification to keep your app's data updated.

Check React-Native Push Notification to create an iOS and Android push project on Stringee dashboard and generate APNs Auth Key for push notification.

Stringee use Remote Push Notification to send push to devices for chat. So, you need to do the following steps:

Get token for remote push notification.

  1. IOS

    In React-Native, you can use any library to get APNS device token for push. For example, if you are using React Native Firebase, you can call the following function to get that token:

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

    On initial startup of your app, the React Native FireBase generates a registration token for the client app instance. When you need to retrieve the current token, call:

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

Register token with Stringee server

Send your device token to Stringee server as follow:

stringeeClient
  .registerPush(
    token,
    false, // (iOS) isProduction, false: In development, true: In Production.
    false // (iOS) isVoip, false: This token is not for voip push.
  )
  .then(()=>{
    console.log('registerPush success');
  })
  .catch(console.log)

Note:

If everything is success, you will receive remote push notifications for chat. Stringee push notification data has the following format:

{
    data = {
        map = {
            data = {
                map = {
                    avatarUrl = "";
                    convId = "conv-vn-1-OZQMBPBUWM-1553965638358";
                    convName = Demo;
                    createdTime = 1554261740264;
                    displayName = hoangnam;
                    from = user1;
                    isGroup = 0;
                    message = {
                        map = {
                            content = Alo;
                            metadata = {
                                map = {};
                            };
                        };

                    };
                    msgId = "msg-vn-1-OZQMBPBUWM-1553965654245";
                    seq = 2;
                    type = 1;
                };
            };
            stringeePushNotification = "1.0";
            type = "CHAT_EVENT";
        };
    };
}