Reputation: 14113
I am using Firebase
for analytics and a library for push notifications. When I use either of them, didReceiveRemoteNotification get called. But when I use them both together, didReceiveRemoteNotification doesn't get called.
Code :
didFinishLaunchingWithOptions :
NSString *google_app_id = @"----";
NSString *gcm_sender_id = @"----";
FIROptions *o = [[FIROptions alloc] initWithGoogleAppID:google_app_id GCMSenderID:gcm_sender_id];
o.APIKey = @"----";
o.bundleID = @"----";
o.clientID = @"----";
[FIRApp configureWithOptions:o];
// Initilization of push framework
didReceiveRemoteNotification :
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// This method is not called when Firebase and push framework are enabled at the same time
// It works fine when only Firebase or only push framework is enabled
NSLog(@"Push: %@", userInfo);
}
Upvotes: 8
Views: 3019
Reputation: 11985
This is because Firebase uses swizzling to intercept methods of the AppDelegate.
You should disable it in your app's info.plist:
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
Actually there is a lot of information about Push Notification in iOS with Firebase on GitHub. You probably will find answers for your further questions there.
Upvotes: 2
Reputation: 32
In the documentation for this method in Firebase Cloud Messaging said:
If you are receiving a notification message while your app is in the background, this callback will not be fired till the user taps on the notification launching the application.
mb this method calls only when you tapped on notification which launch app?
In my experience I deal with pushs with this methods:
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler {
Method get info about coming push notification if app is active. In block you must put constant to show your notification:
completionHandler(UNNotificationPresentationOptionAlert);
And another one:
(void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
This method works with tapping on push notification. Mb here you are working with moving to some special screen.
Hope my exp helps!
Upvotes: -1