1
votes

I have implemented react native firebase push notification on my project, where it works with android properly but not showing on iOS.

  1. iOS project includes GoogleService-info.plist file.
  2. also project capabilities are "on" for push notification and remote notifications in background modes.
  3. I have added APNs authentication key to firebase console.
  4. when app runs on device, it ask for notification permission to user

Expected result: Notification pop-up on both devices android as well as iOS

Actual result: Notification pop-up on android only

Application runs properly, it does not crashes or not throwing any error.

AppDelegate.m file

#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h> //Added This Line
#import "RNFirebaseNotifications.h" //Added This Line
#import "RNFirebaseMessaging.h" //Added This Line
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [FIRApp configure]; //Added This Line
    [RNFirebaseNotifications configure];  //Added This Line
    RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"pushnotificationTest" initialProperties:nil];
    rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    UIViewController *rootViewController = [UIViewController new];
 rootViewController.view = rootView;
    self.window.rootViewController = rootViewController;
    [self.window makeKeyAndVisible];
    [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; //Added This Line
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
1
Are you by any chance trying to run the iOS app on a simulator ? Remote notifications won't work on iPhone simulators. - RDardelet
Hi @RDardelet , I have been testing application on real device only, but it still didn't worked. - Karishma Kavankar
I'm having the same problem and noticed that the message is coming through but only directly through Firebase messages directly, and not through the APNs (for background/push) as I would have hoped. I'm also struggling to find a solution to this. - waffl
I guess the problem comes from Rnfirebase package version because when switching to other services like Onesignal is working fine - krissanawat

1 Answers

0
votes

I recommend you recheck APNs cert. 90% problems reference with wrong APNs gate / cert (if you install on device application with debug cert you need send notification in sandbox gate). If you install app with prod cert like adhock or AppStore - you need send in notification in prod APNs gate.

You can check it with send push notification without firebase. It can do with this tool: https://github.com/noodlewerk/NWPusher

Also i recomend, get more information about environment: react-native-firebase version, iOS version, iOS SDK version, e.t.c.

If you have issue with iOS 13, you can check this issue https://github.com/invertase/react-native-firebase/issues/2565 (maby you have the same problem).

I hope it helples for you.