react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

FIRApp undefined after upgrading to 2.1.0

Open tijs opened this issue 10 years ago • 42 comments

When i upgrade this package to the latest 2.1.0 (from 2.0.3) i get an error that FIRApp is undefined in the Appdelegate.m file:

[FIRApp configure];

I'm using xcode 8. Have not tried on xcode 7. When i revert back to 2.0.3 the issue is gone.

tijs avatar Sep 21 '16 09:09 tijs

same for me when running react-native run-ios:

AppDelegate.m:39:4: error: use of undeclared identifier 'FIRApp'
  [FIRApp configure];
   ^

antoinerousseau avatar Sep 21 '16 11:09 antoinerousseau

@antoinerousseau yeah that's indeed the exact error i get. are you also running xcode 8? i assume something is preventing @evollu from getting the same error...

tijs avatar Sep 21 '16 11:09 tijs

Xcode 7.3

antoinerousseau avatar Sep 21 '16 11:09 antoinerousseau

are you using cocoa pods?

evollu avatar Sep 21 '16 12:09 evollu

i changed import in module from h file to framework, could that be the issue?

evollu avatar Sep 21 '16 12:09 evollu

i am using cocoapods. what can i change to see if thats the issue?

tijs avatar Sep 21 '16 12:09 tijs

yes i'm using cocoapods

antoinerousseau avatar Sep 21 '16 12:09 antoinerousseau

i will try to create a demo project today can you give me screenshot of your appdelegate.m your pods folder

and have you tried clearing the project and rebuild?

evollu avatar Sep 21 '16 12:09 evollu

try add @import Firebase in appdelegatr

evollu avatar Sep 21 '16 12:09 evollu

my AppDeletage.m:

#import "AppDelegate.h"
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

#import "RCTBundleURLProvider.h"
#import "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:@"tribeez"
                                               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];
  [Fabric with:@[[Crashlytics class]]];
  return YES;
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
  fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler
{
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification];
  handler(UIBackgroundFetchResultNewData);
}

@end

My Pods folder:

capture d ecran 2016-09-21 14 49 01

What do you mean clearing the project?

antoinerousseau avatar Sep 21 '16 12:09 antoinerousseau

I'm having the same problem. I made it work by changing +@import Firebase; +@import FirebaseMessaging; inside of ios/rnfirmessage.h to #import "Firebase.h". I don't know if this should be the fix but it worked for me.

jcharbo avatar Sep 21 '16 19:09 jcharbo

it is no long @import Firebase in the code now. Can you get the latest? or I didn't release it?

evollu avatar Sep 21 '16 20:09 evollu

check v2.1.1

evollu avatar Sep 21 '16 20:09 evollu

my version had

@import FirebaseInstanceID;
@import FirebaseMessaging;

and it failed with this.

Now I just tried to update to v2.2.0 and I get:

The following commands produced analyzer issues:
    Analyze RNFIRMesssaging.m
(1 command with analyzer issues)

The following build commands failed:
    Analyze RNFIRMesssaging.m
    CompileC /Users/antoine/Sites/tribeez/ios/build/Build/Intermediates/RNFIRMessaging.build/Debug-iphonesimulator/RNFIRMessaging.build/Objects-normal/x86_64/RNFIRMesssaging.o RNFIRMesssaging.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

antoinerousseau avatar Sep 22 '16 06:09 antoinerousseau

above this error is a fatal one:

node_modules/react-native-fcm/ios/RNFIRMesssaging.m:8:9: fatal error: module 'UserNotifications' not found
@import UserNotifications;
 ~~~~~~~^~~~~~~~~~~~~~~~~

antoinerousseau avatar Sep 22 '16 06:09 antoinerousseau

I'll try to upgrade Xcode from 7 to 8

antoinerousseau avatar Sep 22 '16 06:09 antoinerousseau

just installed Xcode 8 and updated my AppDelegate according to latest README. now I have a bunch of errors (cc @evollu):

/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:28:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitMinute;
           ^~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:31:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitSecond;
           ^~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:34:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitDay;
           ^~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:37:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitMonth;
           ^~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:40:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitWeekOfYear;
           ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:43:12: warning: incompatible integer to pointer conversion returning 'NSUInteger'
      (aka 'unsigned long') from a function with result type 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *') [-Wint-conversion]
    return NSCalendarUnitYear;
           ^~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:63:31: warning: incompatible pointer to integer conversion assigning to 'NSCalendarUnit'
      (aka 'enum NSCalendarUnit') from 'NSCalendarUnit *' (aka 'enum NSCalendarUnit *'); dereference with * [-Wint-conversion]
  notification.repeatInterval = [RCTConvert NSCalendarUnit:details[@"repeat_interval"]];
                              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                *(                                                     )
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:227:43: error: expected a type
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                                          ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:104:29: error: no visible @interface for 'FIRMessaging' declares the selector
      'setRemoteMessageDelegate:'
  [[FIRMessaging messaging] setRemoteMessageDelegate:self];
   ~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:124:106: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
                                                                                                         ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:133:95: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getFCMToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                              ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:144:12: warning: 11 enumeration values not handled in switch: 'NSCalendarUnitEra',
      'NSCalendarUnitHour', 'NSWeekCalendarUnit'... [-Wswitch]
    switch(notif.repeatInterval){
           ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:138:114: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getScheduledLocalNotifications:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                                                 ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:186:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:@"FCMTokenRefreshed" body:[[FIRInstanceID instanceID] token]];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:216:31: warning: unused parameter 'granted' [-Wunused-parameter]
     completionHandler:^(BOOL granted, NSError * _Nullable error) {
                              ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:216:60: warning: unused parameter 'error' [-Wunused-parameter]
     completionHandler:^(BOOL granted, NSError * _Nullable error) {
                                                           ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:96: error: no known instance method for selector 'appData'
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                                                                                               ^~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:269:57: warning: incompatible pointer to integer conversion sending 'NSInteger *' (aka 'long *') to
      parameter of type 'NSInteger' (aka 'long'); dereference with * [-Wint-conversion]
  [RCTSharedApplication() setApplicationIconBadgeNumber:number];
                                                        ^~~~~~
                                                        *
In module 'UIKit' imported from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMessaging.h:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:161:32: note:
      passing argument to parameter 'applicationIconBadgeNumber' here
@property(nonatomic) NSInteger applicationIconBadgeNumber;  // set to 0 to hide. default is 0. In iOS 8.0 and later, your application must register for user notifications us...
                               ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:272:99: warning: unused parameter 'reject' [-Wunused-parameter]
RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
                                                                                                  ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:281:28: warning: 'sendDeviceEventWithName:body:' is deprecated: Subclass RCTEventEmitter instead
      [-Wdeprecated-declarations]
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data];
                           ^
In file included from /Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:5:
../../react-native/React/Base/RCTEventDispatcher.h:70:1: note: 'sendDeviceEventWithName:body:' has been explicitly marked deprecated here
- (void)sendDeviceEventWithName:(NSString *)name body:(id)body
^
18 warnings and 3 errors generated.

...

/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:227:43: error: expected a type
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
                                          ^
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:104:29: error: no visible @interface for 'FIRMessaging' declares the selector
      'setRemoteMessageDelegate:'
  [[FIRMessaging messaging] setRemoteMessageDelegate:self];
   ~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/antoine/Sites/tribeez/node_modules/react-native-fcm/ios/RNFIRMesssaging.m:228:96: error: no known instance method for selector 'appData'
  [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:[remoteMessage appData]];
                                                                                               ^~~~~~~

antoinerousseau avatar Sep 22 '16 08:09 antoinerousseau

@antoinerousseau

[[FIRMessaging messaging] setRemoteMessageDelegate:self];

is introduced in latest firebase SDK. try update your pods also try clear your build?

@import UserNotifications; is introduced with iOS10 SDK. Why do you get this error?

evollu avatar Sep 22 '16 13:09 evollu

how do you clear your build?

antoinerousseau avatar Sep 22 '16 17:09 antoinerousseau

i'll look at your repo and try to fix it @antoinerousseau

evollu avatar Sep 22 '16 18:09 evollu