evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

Application crashes on start with minimal configuration #1006

Closed esomkin closed 6 years ago

esomkin commented 6 years ago

I'am trying to receive push notification with react-native-fcm. As documentation says I'am install and implement all steps as bellow

a) Install react-native-fcm npm install react-native-fcm --save b) Link the library with react-native link react-native-fcm c) Download GoogleService-Info.plist file from firebase console and place it in /ios/my-project directory d) Install Firebase Messaging with Cocoapods

  1. cd ios && pod init
  2. add pod 'Firebase/Messaging' into Podfile
  3. pod install e) Edit AppDelegate.h
    @import UserNotifications;
    @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
    /*@interface AppDelegate : UIResponder <UIApplicationDelegate>*/

    f) Edit AppDelegate.m

    
    #import "RNFIRMessaging.h"
    //...

-(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions { //...

[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]; }


g) Enable capabilities in xCode

 1. Push Notifications
 2. Background Modes > Remote notifications

Then I archive my application in `ipa` and try to start it on device. Application crashes after loading screen appear. Please, explan to me, where is my mistake?

PS. No one `.js` file are not change from `create-react-native-app` command.

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

1. RN 0.55.2, RN-FCM 16.0.0
2. iPhone device, iOS 11.4
3. Application not running?
akyGit commented 6 years ago

I had the same problem. In my case I was to add GoogleService-Info.plist to project via xcode, not just put file in project directory: https://stackoverflow.com/questions/45317777/could-not-find-a-valid-googleservice-info-plist-in-your-project#answer-45318508

esomkin commented 6 years ago

@akyGit Thank you very much, application started!