React-native-fcm: App stuck at splash screen

Created on 8 Oct 2017  路  10Comments  路  Source: evollu/react-native-fcm

When openning an issue, please include following information for better support

  1. What version of RN and react-native-fcm are you running: 0.48.4 and 10.0.0?
  2. What device are you using? (e.g iOS9 emulator, Android 6 device): iOS 9.0 Emulator and ios 10.3.3 phone. The error occurs on both the devices
  3. Is your app running in foreground, background or not running? Foreground

App is stuck at splash screen.

Here are the logs from xcode:

Oct  8 20:59:28  Frills[15019] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Oct  8 20:59:28  Frills[15019] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Oct  8 20:59:28  Frills[15019] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-10-08 15:29:28.305 [info][tid:main][RCTCxxBridge.mm:187] Initializing <RCTCxxBridge: 0x7f83da5a8670> (parent: <RCTBridge: 0x7f83da5e2d20>, executor: (null))
2017-10-08 15:29:28.314 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-10-08 20:59:28.367 Frills[15019] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb
2017-10-08 20:59:28.377 Frills[15019] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4000000 started
2017-10-08 20:59:28.379 Frills[15019] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-10-08 20:59:28.387 Frills[15019] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2017-10-08 20:59:28.433 Frills[15019] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-10-08 20:59:28.450 Frills[15019] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
2017-10-08 20:59:28.486 Frills[15019] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled

This is my pod file:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

pod 'Firebase/Core', '4.0.0'
pod 'Firebase/Messaging'

target 'AppName' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for AppName

  target 'AppNameTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

This is my AppDelegate.m file

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"
#import "RNFIRMessaging.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#import "RCCManager.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  // RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
  //                                                     moduleName:@"Frills"
  //                                              initialProperties:nil
  //                                                  launchOptions:launchOptions];
  // 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];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions];

  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  return YES;
}

// URL SCHEME HANDLING CODE
- (BOOL)application:(UIApplication *)application
   openURL:(NSURL *)url
   options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
 return [RCTLinkingManager application:application
                  continueUserActivity:userActivity
                    restorationHandler:restorationHandler];
}


- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

#if defined(__IPHONE_11_0)
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
  [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#else
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler
{
  [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#endif

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFIRMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

// END OF SCHEME HANDLING


@end

question

Most helpful comment

Adding GoogleService-info.plist itself didnt solve the problem . I had to Click on the
Target app > Build phases , within which I had to add GoogleService-info.plist manually to the Copy Bundle Resources section.
screen shot 2017-12-15 at 5 32 18 pm

This fixed it for me . Hope this finds some relevance in your projects

All 10 comments

@evollu Im guessing something is wrong in the AppDelegate.m file. My app is just stuck at launch screen, because if I replace my AppDelegate with this:

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import "RNFIRMessaging.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Test"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  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];

  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  return YES;
}


- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

#if defined(__IPHONE_11_0)
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
  [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#else
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler
{
  [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#endif

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFIRMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

@end

the app boots up. This is not a solution though, I need react-native-navigations navigation.

I don't think this repo is the caused.
if you removes

  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

what happens

@evollu My bad. My packager was not running! 馃槄

@srameshr : what do you mean by "my packager was not running" ? i have this issue only in device when deploying on staging or production .

I deleted the project, stopped react native node server and restarted everything. It worked

thanks for your response . i think that for me is more complicated , i can build normally my iOS application in simulator or device in debug between deploying in staging or release my application freeze with white screen after passing the splash screen .
id ont have this problem in android .
"@expo/ex-navigation": "^3.1.0",
"assert": "^1.4.1",
"babel-preset-react-native-stage-0": "^1.0.1",
"bamlab-react-native-smooch": "^0.3.0",
"base-64": "^0.1.0",
"browserify-zlib": "^0.1.4",
"bytebuffer": "^5.0.1",
"console-browserify": "^1.1.0",
"constants-browserify": "^1.0.0",
"dns.js": "^1.0.1",
"domain-browser": "^1.1.7",
"events": "^1.1.1",
"https-browserify": "0.0.1",
"install": "^0.10.1",
"lodash": "^4.17.4",
"mockdate": "^2.0.2",
"moment": "^2.19.1",
"net": "^1.0.2",
"numeral": "^2.0.4",
"path-browserify": "0.0.0",
"process": "^0.11.10",
"prop-types": "^15.6.0",
"querystring": "^0.2.0",
"querystring-es3": "^0.2.1",
"react": "16.0.0",
"react-native": "0.49.3",
"react-native-crypto": "^2.1.1",
"react-native-datepicker": "^1.6.0",
"react-native-drawer-layout": "^1.3.2",
"react-native-fbsdk": "^0.6.3",
"react-native-fetch-blob": "^0.10.8",
"react-native-form-idable": "^1.0.2",
"react-native-gcm-android": "^0.2.0",
"react-native-google-analytics-bridge": "^5.0.1",
"react-native-http": "github:tradle/react-native-http#834492d",
"react-native-i18n": "^1.0.0",
"react-native-level-fs": "^3.0.0",
"react-native-linear-gradient": "^2.3.0",
"react-native-md5": "^1.0.0",
"react-native-navigation": "^1.1.260",
"react-native-os": "^1.1.0",
"react-native-push-notification": "^3.0.0",
"react-native-randombytes": "^3.0.0",
"react-native-root-siblings": "^1.2.1",
"react-native-root-toast": "^1.3.0",
"react-native-svg": "^5.4.2",
"react-native-swipeout": "^2.2.2",
"react-native-swiper": "^1.5.13",
"react-native-system-notification": "^0.2.1",
"react-native-tcp": "^3.3.0",
"react-native-udp": "^2.2.0",
"react-native-vector-icons": "^4.4.2",
"react-redux": "^5.0.6",
"react-static-container": "^1.0.1",
"readable-stream": "^1.0.33",
"redux": "^3.6.0",
"redux-enhancer-react-native-appstate": "^0.1.1",
"redux-logger": "^2.7.4",
"redux-persist": "^4.4.1",
"redux-saga": "^0.14.3",
"stream-browserify": "^1.0.0",
"superagent": "^3.3.2",
"timers-browserify": "^1.4.2",
"tty-browserify": "0.0.0",
"url": "^0.10.3",
"victory-native": "^0.15.0",
"vm-browserify": "0.0.4"

/**

  • Copyright (c) 2015-present, Facebook, Inc.
  • All rights reserved.
    *
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. An additional grant
  • of patent rights can be found in the PATENTS file in the same directory.
    */

import "AppDelegate.h"

import

import

import

import

import

import

@implementation AppDelegate

// Required to register for notifications

  • (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
    {
    [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
    }
    // Required for the register event.
  • (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
    {
    [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }
    // Required for the registrationError event.
  • (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
    [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
    }
    // Required for the localNotification event.
  • (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    {
    [RCTPushNotificationManager didReceiveLocalNotification:notification];
    }

@end

thanks for your help

@nadirHomeFriend The same thing is happening to me, did you find a solution?

Open Xcode
Move your GoogleService-Info.plist file to the "Resources" folder in the Project Navigator
Source: https://github.com/evollu/react-native-fcm/issues/322#issuecomment-281678346

Update [email protected] works for me!

Adding GoogleService-info.plist itself didnt solve the problem . I had to Click on the
Target app > Build phases , within which I had to add GoogleService-info.plist manually to the Copy Bundle Resources section.
screen shot 2017-12-15 at 5 32 18 pm

This fixed it for me . Hope this finds some relevance in your projects

Was this page helpful?
0 / 5 - 0 ratings