|
@@ -20,32 +20,52 @@ TaskManager.defineTask(
|
|
|
const token = storage.get('token', StoreType.STRING);
|
|
|
let groupToken;
|
|
|
let messageId;
|
|
|
+ let fromUser;
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
- groupToken = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.group_token;
|
|
|
- messageId = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.message_id;
|
|
|
+ groupToken = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.data?.group_token;
|
|
|
+ messageId = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.data?.message_id;
|
|
|
+ fromUser = data?.UIApplicationLaunchOptionsRemoteNotificationKey?.data?.from_user;
|
|
|
} else {
|
|
|
groupToken = data?.notification?.data?.group_token;
|
|
|
messageId = data?.notification?.data?.message_id;
|
|
|
+ fromUser = data?.notification?.data?.from_user;
|
|
|
}
|
|
|
|
|
|
- if (!groupToken || !messageId) return;
|
|
|
+ if ((!groupToken && !fromUser) || !messageId) return;
|
|
|
|
|
|
try {
|
|
|
- await axios.postForm(
|
|
|
- API_URL + '/' + API.GROUP_MESSAGES_RECEIVED,
|
|
|
- {
|
|
|
- token,
|
|
|
- group_token: groupToken,
|
|
|
- messages_id: [messageId]
|
|
|
- },
|
|
|
- {
|
|
|
- headers: {
|
|
|
- Platform: Platform.OS,
|
|
|
- 'App-Version': APP_VERSION
|
|
|
+ if (fromUser) {
|
|
|
+ await axios.postForm(
|
|
|
+ API_URL + '/' + API.MESSAGES_RECEIVED,
|
|
|
+ {
|
|
|
+ token,
|
|
|
+ from_user: fromUser,
|
|
|
+ messages_id: [messageId]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ Platform: Platform.OS,
|
|
|
+ 'App-Version': APP_VERSION
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- );
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ await axios.postForm(
|
|
|
+ API_URL + '/' + API.GROUP_MESSAGES_RECEIVED,
|
|
|
+ {
|
|
|
+ token,
|
|
|
+ group_token: groupToken,
|
|
|
+ messages_id: [messageId]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ headers: {
|
|
|
+ Platform: Platform.OS,
|
|
|
+ 'App-Version': APP_VERSION
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
} catch (err) {
|
|
|
console.error('Error sending notification data:', err);
|
|
|
}
|