React-native-fcm: Use of undeclared identifier 'FCMNotificationReceived'

Created on 18 Jul 2016  路  11Comments  路  Source: evollu/react-native-fcm

After following your installation guide (following the 'Non Cocoapod approach'), and pasting in this code:

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

I get the following error: Use of undeclared identifier 'FCMNotificationReceived'

Any idea why?

Pretty sure I added all the files the right way.

Most helpful comment

@evollu actually i was following this tutorial for push notification where i got this error.
http://nobrok.com/push-notification-using-react-native-and-firebase-part-3/

so for those who are following this tutorial and have this issue then replace the code

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

* with this **

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

All 11 comments

Ah, never mind. It works now.

I forgot to add #import "RNFIRMessaging.h" :)

I currently facing same issue. I made sure that i didnt forget any imports or such.

@krishnazden What version of _react-native_ and _react-native-fcm_ are you using?
I was using 0.39 and 2.5.6 and all was good.
Upgraded react-native to 0.44 and things broke; needed to upgrade _react-native-fcm_.
Naively picked 6.2.3 as it looked stable and saw this error.
Interim fix for me was to use 3.0.0 instead (which just fixed 0.39 -> 0.40 upgrade).
Looks like it was maybe commit eb9b29fe4b3d50486588524bb581899a48e57da8 (introduced at 6.0.1, so prior version, 5.0.0, may suit you?).
In that commit the _FCMNotificationReceived_ constant went away in ios/RNFIRMessaging.h
Disclaimer: sort of new here.

Hello Guys ... I am having the same issue ... I have
react-native: 0.50.4
react-native-fcm: ^11.2.0
Any suggestions ? What could be I am doing wrong ... all the imports are in place. Thanks

Hi,
I am also having the same issue. I am using:

    "react-native": "0.52.0",
    "react-native-fcm": "^11.2.0",
    "react-navigation": "^1.0.0-beta.23",

Could someone help with this problem?
Thanks!

@pepincho ... I have the same issue as well and as you can see that I have the same versions as yours ... I resolved the issue by using the code provided on the repo for iOS ... previously I was using the code from a tutorial I saw and I think that tutorial was outdated ...

use this code instead of tutorial one

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

Hope it will work fine

@danyleo what is the difference between this and the tutorial one?

@evollu actually i was following this tutorial for push notification where i got this error.
http://nobrok.com/push-notification-using-react-native-and-firebase-part-3/

so for those who are following this tutorial and have this issue then replace the code

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

* with this **

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

@danyleo ok. the readme has the right one then

for people with zero knowledge of Objective C like me you have add an "-" before @evollu answer
eg

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

it took me 40 minuts to find out :-)

Was this page helpful?
0 / 5 - 0 ratings