|
@@ -11,25 +11,33 @@ const BACKGROUND_NOTIFICATION_TASK = 'BACKGROUND-NOTIFICATION-TASK';
|
|
|
TaskManager.defineTask(
|
|
|
BACKGROUND_NOTIFICATION_TASK,
|
|
|
async ({ data, error }: { data?: any; error?: any }) => {
|
|
|
- console.log('Background notification task started');
|
|
|
+ console.log('Background notification task started', data);
|
|
|
if (error) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (data) {
|
|
|
const token = storage.get('token', StoreType.STRING);
|
|
|
+ let groupToken;
|
|
|
+ let messageId;
|
|
|
|
|
|
- const { notification } = data;
|
|
|
+ if (Platform.OS === 'ios') {
|
|
|
+ groupToken = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.group_token;
|
|
|
+ messageId = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.message_id;
|
|
|
+ } else {
|
|
|
+ groupToken = data?.notification?.data?.group_token;
|
|
|
+ messageId = data?.notification?.data?.message_id;
|
|
|
+ }
|
|
|
|
|
|
- if (!notification.data?.group_token || !notification.data?.message_id) return;
|
|
|
+ if (!groupToken || !messageId) return;
|
|
|
|
|
|
try {
|
|
|
- const response = await axios.postForm(
|
|
|
+ await axios.postForm(
|
|
|
API_URL + '/' + API.GROUP_MESSAGES_RECEIVED,
|
|
|
{
|
|
|
token,
|
|
|
- group_token: notification.data.group_token,
|
|
|
- messages_id: [notification.data.message_id]
|
|
|
+ group_token: groupToken,
|
|
|
+ messages_id: [messageId]
|
|
|
},
|
|
|
{
|
|
|
headers: {
|