Suggestions

close search

Push notification

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

Check Flutter Push Notification to create an iOS 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:

1. Get token for remote push notification.

In Flutter, you can use any library to get APNS device token for push. For example, if you are using FlutterFire, you can call the fllowing function to get that token:

FirebaseMessaging.instance.getAPNSToken();

2. Register token with Stringee server

Send your device token to Stringee server as follow:

    InstanceManager.client.registerPush(pushToken, isProduction: false, isVoip: false).then((result) {
      bool status = result['status'];
      String message = result['message'];
      print('Result for resgister push: ' + message);
    });

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";
        };
    };
}