Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(firebase_messaging): ensure silent foreground messages for iOS are called via event channel. #8635

Merged
merged 4 commits into from May 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -422,6 +422,7 @@ - (void)application:(NSApplication *)application
#endif

#if !TARGET_OS_OSX
// Called for silent notifications in the foreground & background
- (BOOL)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
Expand All @@ -431,12 +432,10 @@ - (BOOL)application:(UIApplication *)application
return YES;
}
#endif

NSDictionary *notificationDict =
[FLTFirebaseMessagingPlugin remoteMessageUserInfoToDict:userInfo];
// Only handle notifications from FCM.
if (userInfo[@"gcm.message_id"]) {
NSDictionary *notificationDict =
[FLTFirebaseMessagingPlugin remoteMessageUserInfoToDict:userInfo];

if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
__block BOOL completed = NO;

Expand Down Expand Up @@ -485,6 +484,11 @@ - (BOOL)application:(UIApplication *)application
}
}];
} else {
// If "alert" (i.e. notification) is present, this will be called by the other
// "Messaging#onMessage" channel handler
if (notificationDict[@"aps"] != nil && notificationDict[@"aps"][@"alert"] == nil) {
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
}
completionHandler(UIBackgroundFetchResultNoData);
}

Expand Down