Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didReceiveRemoteNotification not called when Firebase is used along with Push framework

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);
}
like image 303
Nitish Avatar asked Oct 29 '18 19:10

Nitish


1 Answers

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.

like image 130
kelin Avatar answered Oct 08 '22 08:10

kelin