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 Flutter Push Notification to create an flutter 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:
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 following function to get that token:
String? pushToken = '';
if (Platform.isAndroid) {
pushToken = await FirebaseMessaging.instance.getToken();
} else {
pushToken = await FirebaseMessaging.instance.getAPNSToken();
}
Send your device token to Stringee server as follow:
_stringeeClient.registerPush(pushToken!, isProduction: false, isVoip: false).then((result) {
debugPrint('registerPush: message - ${result['message']}');
});
For ios:
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";
};
};
}