I have implemented react native firebase push notification on my project, where it works with android properly but not showing on iOS.
- iOS project includes GoogleService-info.plist file.
- also project capabilities are "on" for push notification and remote notifications in background modes.
- I have added APNs authentication key to firebase console.
- 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