Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

react native firebase push notification issues only on iOS

$
0
0

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

Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>