Push notifications stopped showing on iOS with RN Firebase 6.7.1

1.8k views Asked by At

My app is using RN Firebase for push notification, it is still on 6.7.1. After removing node_modules the notifications stopped appearing on iOS. I did not do any changes to GoogleService-Info.plist or whichever config file package.json.

There is no trace of any notification event in the native/RN log. They still continue working normally on Android.

Before the problem occurred, my last package.json specified ^6.4.0of RN Firebase - I was very likely using the same version of it and other packages.

FCM shows success...

curl --header "Content-Type: application/json" \
--header "Authorization: key=AAA...my-server-key...oEw" \
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"title": "my notification", "body": "test message", "sound": "default"},
"priority": "high",
"to": "clV...my-fcm-token...CL9"}'

Response:
{
    "multicast_id":3203896278802626969,
    "success":1,
    "failure":0,
    "canonical_ids":0,
    "results": [
        {
            "message_id":"0:1601380177966694%89df1e3089df1e30"
        }
    ]
}

...but no trace of the notification on the client

2020-09-29 13:46:54.241363+0200 MyApp[10459:756113] 6.30.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://xxx.
2020-09-29 13:46:54.379384+0200 MyApp[10459:755952] [Firebase/Crashlytics] Version 4.4.0
2020-09-29 13:46:54.390700+0200 MyApp[10459:756110] 6.30.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60702000 started
2020-09-29 13:46:54.393020+0200 MyApp[10459:756110] 6.30.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://xxx)
2020-09-29 13:46:54.431519+0200 MyApp[10459:756111] 6.30.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2020-09-29 13:46:54.444616+0200 MyApp[10459:755952] +[RNFBCrashlyticsInitProvider isCrashlyticsCollectionEnabled] [Line 47] isCrashlyticsCollectionEnabled via RNFBMeta: 1
2020-09-29 13:46:54.444692+0200 MyApp[10459:755952] +[RNFBCrashlyticsInitProvider isCrashlyticsCollectionEnabled] [Line 50] isCrashlyticsCollectionEnabled: 1
2020-09-29 13:46:54.446565+0200 MyApp[10459:755952] +[RNFBCrashlyticsInitProvider configureWithApp:] [Line 71] initialization successful
2020-09-29 13:46:54.975676+0200 MyApp[10459:756115] 6.30.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics logEventWithName:FIREventScreenView parameters:] to log a screen view event. To disable automatic screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-09-29 13:46:59.354475+0200 MyApp[10459:756131] 6.30.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-09-29 13:46:59.688 [info][tid:com.facebook.react.JavaScript] FirebaseService createNotificationListeners
2020-09-29 13:46:59.688 [warn][tid:com.facebook.react.JavaScript] Usage of "messaging().registerDeviceForRemoteMessages()" is not required. You only need to register if auto-registration is disabled in your 'firebase.json' configuration file via the 'messaging_ios_auto_register_for_remote_messages' property.
2020-09-29 13:47:00.062 [info][tid:com.facebook.react.JavaScript] 'FirebaseService checkMessagingPermission messaging 1', -1
2020-09-29 13:47:00.182 [info][tid:com.facebook.react.JavaScript] 'NotificationService TOKEN:', { token: '193...-token-...afe',
  os: 'ios' }
2020-09-29 13:47:00.248852+0200 MyApp[10459:756257] 6.30.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-09-29 13:47:00.382232+0200 MyApp[10459:756132] 6.30.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled
2020-09-29 13:47:02.619 [info][tid:com.facebook.react.JavaScript] 'NotificationService TOKEN:', { token: '193...-token-...afe',
  os: 'ios' }
2020-09-29 13:47:02.621 [info][tid:com.facebook.react.JavaScript] 'isNotificationsGranted() checkNotifications', { status: 'granted',
  settings: 
   { sound: true,
     badge: true,
     lockScreen: true,
     alert: true,
     notificationCenter: true } }
2020-09-29 13:47:02.627 [info][tid:com.facebook.react.JavaScript] 'FirebaseService checkPermission notifications 2', true
2020-09-29 13:47:02.628 [info][tid:com.facebook.react.JavaScript] 'FirebaseService checkPermission result 3', -1, true
2020-09-29 13:47:05.341 [info][tid:com.facebook.react.JavaScript] FirebaseService fcmToken 0
2020-09-29 13:47:05.435 [info][tid:com.facebook.react.JavaScript] 'isNotificationsGranted() checkNotifications', { status: 'granted',
  settings: 
   { sound: true,
     badge: true,
     lockScreen: true,
     alert: true,
     notificationCenter: true } }
2020-09-29 13:47:05.444 [info][tid:com.facebook.react.JavaScript] 'FirebaseService fcmToken 1', null
2020-09-29 13:47:05.732 [info][tid:com.facebook.react.JavaScript] 'FirebaseService fcmToken 2', 'clV...-my-fcm-token-...CL9'
2020-09-29 13:47:05.743 [info][tid:com.facebook.react.JavaScript] 'CaptureScreen this._user_id', 'clV...-my-fcm-token-...CL9'

iOS permissions: iOS permissions

Last package.json known to work on iOS:

"dependencies": {
    "@react-native-community/push-notification-ios": "^1.4.1",
    "@react-native-firebase/analytics": "^6.4.0",
    "@react-native-firebase/app": "^6.4.0",
    "@react-native-firebase/crashlytics": "^6.4.0",
    "@react-native-firebase/iid": "^6.4.0",
    "@react-native-firebase/messaging": "^6.4.0",
    "react-native-push-notification": "^5.1.0",
    ...
}

Currently installed versions npm ls --depth=0:

├─┬ UNMET DEPENDENCY @react-native-community/[email protected]
│ └── [email protected]
├── UNMET DEPENDENCY @react-native-firebase/[email protected]
├─┬ UNMET DEPENDENCY @react-native-firebase/[email protected]
│ ├── @react-native-firebase/[email protected]
│ ├── [email protected]
│ └── [email protected]
├── UNMET DEPENDENCY @react-native-firebase/[email protected]
├─┬ UNMET DEPENDENCY @react-native-firebase/[email protected]
│ └── [email protected]
├── UNMET DEPENDENCY @react-native-firebase/[email protected]
├── UNMET DEPENDENCY @react-native-firebase/[email protected]
├── UNMET DEPENDENCY [email protected]
1

There are 1 answers

0
Peter G. On

I was using the wrong server key from another project. The Firebase console does not show anything, as if everything went successfully. This command produced the necessary output for debugging:

SERVER_KEY="AAA...my-server-key...oEw"
FCM_TOKEN="ef2...my-fcm-token...7PT"
curl --header "Content-Type: application/json" \
--header "Authorization: key=$SERVER_KEY" \
https://fcm.googleapis.com/fcm/send \
-d '{"notification": {"title": "my notification", "body": "test message", "sound": "default"},
"priority": "high",
"to": "'$FCM_TOKEN'"}'

Second problem was that Firebase proxy was switched off - that is when the above command returned success, but the notification still didn't appear in the app, fix it to: FirebaseAppDelegateProxyEnabled: YES