Open
Description
[REQUIRED] Please fill in the following fields:
- Pre-built SDK from the website or open-source from this repo: website
- Firebase C++ SDK version: 7.0.2
- Problematic Firebase Component: Messaging
- Other Firebase Components in use: Analytics
- Platform you are using the C++ SDK on: Unity
- Platform you are targeting: iOS
[REQUIRED] Please describe the issue here:
Unity didn't get any message data if user tapped on custom notification action button if application was fully closed. I'm not quite sure is this issue valid on iOS 12.0 and lower, but potentially this issue happened on iOS 13.0 and higher. My device working on iOS 14.4
Steps to reproduce:
- Add NotificationExtensionsService to your Xcode project.
- Declare custom actions. UNNotificationAction should have options setted to UNNotificationActionOptions.
- Send notification payload with categoryIdentifier, that add custom action buttons in presented notification.
- Check if application fully closed.
- Tap on custom notification action button.
- When application was fully loaded you didn't get any message data.
Relevant Code:
As I understand, this issue happend just because on iOS 13.0 and higher, function application:didFinishLaunchingWithOptions: no longer gets launchOptions when user launches application from custom notification action button. So on iOS 13.0+ we never gets any message data on Unity side.
I'm not quite sure, but I see only one solution of this issue. Add else brach handling in firebase-cpp-sdk/messaging/src/ios/messaging.mm inside function:
- (void)userNotificationCenter:(UNUserNotificationCenter *)notificationCenter
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler {
if (::firebase::messaging::MessagingIsInitialized()) {
NSDictionary *userInfo = [[[[response notification] request] content] userInfo];
#if !defined(NDEBUG)
::firebase::LogInfo("FCM: userInfo: %s.", userInfo.description.UTF8String);
#endif
::firebase::messaging::g_message_notification_opened = true;
::firebase::messaging::NotifyApplicationAndServiceOfMessage(userInfo);
id<UNUserNotificationCenterDelegate> user_delegate = ::firebase::messaging::g_user_delegate;
[user_delegate userNotificationCenter:notificationCenter
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
else
{
if (@available(iOS 13.0, *))
{
::firebase::messaging::g_launch_notification = userInfo;
}
}
}