setBackgroundMessageHandler is not triggering with data only payload in iOS. [Payload 2]
It is working fine with notification + data payload [Payload 1] in both killed + background state. onMessage is also working fine in iOS.
Every use case is working fine in android.
Payload 1 : notification + data
{
"message":{
"token":"f2kvif1Bh......WIhLc",
"notification":{
"title":"Title",
"body":"Body"
},
"data":{
"navigate":"ScreenName"
},
"android":{
"priority":"HIGH"
},
"apn":{
"payload":{
"aps":{
"content-available":1
}
}
}
}
}
Payload 2 : data only
{
"message":{
"token":"f2kvif......WIhLc",
"notification":{
"title":"This is the title of the notification",
"body":"This is the body of the notification"
},
"data":{
"navigate":"ScreenName"
},
"android":{
"priority":"HIGH"
},
"apn":{
"payload":{
"aps":{
"content-available":1
}
}
}
}
}
I am using this Rest API interface for sending push notification
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send
The device I am testing on :
iPhone 11 OS 13.3.1
Click To Expand
#### `package.json`:
{
"name": "wowchess",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@expo/react-native-action-sheet": "^3.4.0",
"@react-native-community/async-storage": "^1.6.3",
"@react-native-community/datetimepicker": "^2.1.0",
"@react-native-community/google-signin": "^3.0.3",
"@react-native-community/netinfo": "^5.7.1",
"@react-native-community/viewpager": "^3.1.0",
"@react-native-firebase/analytics": "^6.7.1",
"@react-native-firebase/app": "^6.7.1",
"@react-native-firebase/crashlytics": "^6.7.1",
"@react-native-firebase/messaging": "^6.7.1",
"@react-native-firebase/perf": "^6.7.3",
"axios": "^0.19.2",
"chess.js": "^0.10.2",
"country-list": "^2.2.0",
"formik": "^2.0.6",
"jsrsasign": "^8.0.12",
"lodash": "^4.17.15",
"moment-timezone": "^0.5.27",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-elements": "^1.2.7",
"react-native-extended-stylesheet": "^0.12.0",
"react-native-fbsdk": "^1.1.1",
"react-native-flags": "^1.0.0",
"react-native-gesture-handler": "^1.5.1",
"react-native-image-picker": "^1.1.0",
"react-native-indicators": "^0.17.0",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-native-scrollable-tab-view": "^1.0.0",
"react-native-share": "^2.0.0",
"react-native-simple-toast": "^1.0.0",
"react-native-sound": "^0.11.0",
"react-native-svg": "^9.13.3",
"react-native-swiper": "^1.6.0-rc.1",
"react-native-tab-view": "^2.11.0",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^8.1.2",
"react-navigation": "^4.0.10",
"react-navigation-backhandler": "^1.3.2",
"react-navigation-header-buttons": "^3.0.4",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.6.0",
"react-redux": "^7.1.3",
"realm": "^3.5.0",
"redux": "^4.0.4",
"socket.io-client": "2.1.1",
"yup": "^0.27.0"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"src/assets/icons"
]
}
}
#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'wowchess' do
# Pods for wowchess
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
target 'wowchessTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'wowchess-tvOS' do
# Pods for wowchess-tvOS
target 'wowchess-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
#### `AppDelegate.m`:
//**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <FBSDKApplicationDelegate.h>
#import <Firebase.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"wowchess"
initialProperties:nil];
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];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options] || [RNGoogleSignin application:application openURL:url options:options];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:
// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->
Click To Expand
**`react-native info` output:**
System:
OS: macOS 10.15.3
CPU: (12) x64 Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
Memory: 1.38 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.18.0 - /usr/local/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native: 0.61.5
- **Platform that you're experiencing the issue on**:
- [x] iOS
- [ ] Android
- [ ] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- `6.7.1`
- **`Firebase` module(s) you're using that has the issue:**
- `@react-native-firebase/messaging`
- **Are you using `TypeScript`?**
- `N`
React Native Firebase and Invertase on Twitter for updates on the library.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.
Any one got it solved ?
Getting the same issue
According to firebase docs content-available should be content_available; an underscore instead of a dash
https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref
And the value 1 should be a boolean instead of a number
Have you tried these? ;o
Also I think it should be apns not apn
As part of the work on #4104 several PRs have been merged, including one just merged and released now as @react-native-firebase/7.8.4
We believe FCM messages will be handled now:
content-available and priority headers correctly in your JSON payload We are no longer aware of cases that don't have known solutions.
If you can reproduce a case after updating to the latest code and running npx react-native-clean-project to make sure you have a clean build, please open a new issue post an App.js that demonstrates the problem.
Most helpful comment
Getting the same issue