Skip to content

Commit

Permalink
fix(messaging, ios): revert "fix(messaging, ios): only call onMessage…
Browse files Browse the repository at this point in the history
… handler if message is data-only or undelivered" (#5641)

* Revert "lint fixes"

This reverts commit 6067c5f.

* Revert "fix: onMessage to only trigger for data-only or undelivered messages"

This reverts commit a31643b.
  • Loading branch information
helenaford authored Aug 24, 2021
1 parent f03589d commit f2162b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
12 changes: 3 additions & 9 deletions packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,10 @@ - (void)application:(UIApplication *)application
[sharedInstance.conditionBackgroundMessageHandlerSet unlock];
}
} else {
// TODO: send an event to track notification has been delivered (possible needs a new event
// handler for `didReceiveRemoteNotification`) Only sends for data-only messages
DLog(@"didReceiveRemoteNotification while app was in foreground");
if (userInfo[@"aps"][@"alert"] == nil) {
DLog(@"didReceiveRemoteNotification send event for data-only message while app was in "
@"foreground");
[[RNFBRCTEventEmitter shared]
sendEventWithName:@"messaging_message_received"
body:[RNFBMessagingSerializer remoteMessageUserInfoToDict:userInfo]];
}
[[RNFBRCTEventEmitter shared]
sendEventWithName:@"messaging_message_received"
body:[RNFBMessagingSerializer remoteMessageUserInfoToDict:userInfo]];
completionHandler(UIBackgroundFetchResultNoData);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
if (notification.request.content.userInfo[@"gcm.message_id"]) {
NSDictionary *notificationDict = [RNFBMessagingSerializer notificationToDict:notification];

// Always send an event to know there is an incoming message in the foreground
// Client app will have to display the notification as `UNNotificationPresentationOptionNone` is
// always sent to completion handler (see below)
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_message_received"
body:notificationDict];
// Don't send an event if contentAvailable is true - application:didReceiveRemoteNotification
// will send the event for us, we don't want to duplicate them
if (!notificationDict[@"contentAvailable"]) {
[[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_message_received"
body:notificationDict];
}

// TODO in a later version allow customizing completion options in JS code
// TODO in a later version allow customising completion options in JS code
completionHandler(UNNotificationPresentationOptionNone);
}

Expand Down

1 comment on commit f2162b7

@vercel
Copy link

@vercel vercel bot commented on f2162b7 Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.