React-native-firebase: Problem with push notifications after updating to React Native 0.61.x on iPhone

Created on 13 Nov 2019  路  20Comments  路  Source: invertase/react-native-firebase

I have working notifications in my app when running on React Native 0.59.x. After updating to RN 0.61.2 firebase.notifications().onNotification() is not fired and the method firebase.messaging().onMessage() is called instead (without any message and don't work when app is in background). On Android the same code for push notifications works perfectly.

On launch when requesting permissions for notifications in the console I see:

[Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: no valid "aps-environment" permission string was found for the application

As everything worked on the previous version of RN, I have all certificates properly configured, push notifications are enabled in "Profiles" on https://developer.apple.com/ and in the application. I've also added a file named xxx.entitlements as a Code Signing Entitlements. I've made a lot of tries after reading stackoverflow/github comments and everything failed. Of course, I'm testing on real device not the simulator.


Project Files






iOS

Click To Expand

#### `ios/Podfile`: - [x] I'm using Pods and my Podfile looks like: ``` pod 'Firebase/Core', '~> 6.3.0' pod 'Firebase/Messaging'

#### `AppDelegate.m`:

```objc

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  [RNFirebaseNotifications configure];

  return YES;
}

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

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

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}


Environment

Click To Expand

react-native info output:

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 47.63 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.4.0 - /usr/local/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 23, 26, 27, 28
      Build Tools: 28.0.3, 29.0.2
      System Images: android-25 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: ^16.11.0 => 16.11.0 
    react-native: ^0.61.2 => 0.61.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1
Messaging

Most helpful comment

I found solution.
Upgrade pod file.
pod 'Firebase/Core', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'
pod 'Firebase/Messaging', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'

All 20 comments

same issue

Environment

System:
OS: macOS 10.15
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 39.11 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 18, 19, 21, 23, 24, 26, 27, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1

Same issue, I don't found the correct code for receive notification in AppDelegate.m

Same issue. anybody have any fixes so far?

Same issue if i am going to send directly from firebase it's working fine but when i am testing with registered FCM token nothing happened.

the same issue

react-native: 0.60.4
same issue. anybody fixed it?

@armilano I am not sure if its the same problem, but I had to add a this.onTokenRefreshListener = firebase.messaging().onTokenRefresh(fcmToken => { // Process your token as required console.log("Token Refreshed", fcmToken); AsyncStorage.setItem('fcmToken', fcmToken); });

My issue is specifically about not being able to send PN to some users

@armilano I am not sure if its the same problem, but I had to add a this.onTokenRefreshListener = firebase.messaging().onTokenRefresh(fcmToken => { // Process your token as required console.log("Token Refreshed", fcmToken); AsyncStorage.setItem('fcmToken', fcmToken); });

My issue is specifically about not being able to send PN to some users

put it in getToken(),right?

no, separate.

Mine is in async componentDidMount()
And then in componentWillUnmount(): this.onTokenRefreshListener();

Hope it helps

I found solution.
Upgrade pod file.
pod 'Firebase/Core', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'
pod 'Firebase/Messaging', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'

I am facing same problem. Upgrading pod file doesnot work on me.

I found solution.
Upgrade pod file.
pod 'Firebase/Core', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'
pod 'Firebase/Messaging', '~> 6.10.0' or pod 'Firebase/Core', '~> 6.5.0'

I tried. but no hope

react-native 0.61.5 same issue, was working correctly in 0.59.10

Anyone with a solution?

the same issue

found this
https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/

but i have zero knowledge on native IOS developing. That first part on "Push Token Retrieval Changes". Could that be the case?

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Here is the solution: https://stackoverflow.com/questions/27324020/no-valid-aps-environment-entitlement-string-found-for-application-on-app-store.

If you need to enable background notification, I think the Background Mode with Remote nofitication Capability also should be added through the Xcode as below:

image

Closing as superseded by all the fixes in #3339 - please check out the RC release, v6.4.0-rc4

Thanks

Was this page helpful?
0 / 5 - 0 ratings