Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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