invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.53k stars 2.19k forks source link

🔥 [IOS] Unable to receive data-only message when App is closed/killed #2741

Closed YoonhaHeo closed 4 years ago

YoonhaHeo commented 4 years ago

Issue

In Docs, when app is closed Data-only message can be received when app is next opened in IOS but it doesn't seem it's receiving any payloads.

In my case, both foreground and background (IOS) work well but app-closed.

Any solution for this? Thanks for helping!


Project Files

iOS

Click To Expand

#### `ios/Podfile`: - [] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'connecting' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks! pod 'React', :path => '../node_modules/react-native', :subspecs => [ 'ART', 'Core', 'CxxBridge', # Include this for RN >= 0.47 'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43 'RCTActionSheet', 'RCTAnimation', 'RCTBlob', 'RCTGeolocation', 'RCTImage', 'RCTLinkingIOS', 'RCTNetwork', 'RCTSettings', 'RCTText', 'RCTVibration', 'RCTWebSocket', 'RCTPushNotification', 'RCTGeolocation', 'RCTPushNotification' ] # Explicitly include Yoga if you are using RN >= 0.42.0 pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' # Third party deps podspec link 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' pod 'Firebase/Core', '~> 5.20.2' pod 'Firebase/Messaging', '~> 5.20.2' pod 'Firebase/RemoteConfig', '~> 5.20.2' pod 'Fabric', '~> 1.9.0' pod 'Crashlytics', '~> 3.12.0' pod 'FBSDKCoreKit', '4.39.1' pod 'FBSDKLoginKit', '4.39.1' pod 'FBSDKShareKit', '4.39.1' pod 'KakaoOpenSDK' pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient' pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc' pod 'react-native-appsflyer', :path => '../node_modules/react-native-appsflyer' pod 'react-native-contacts', :path => '../node_modules/react-native-contacts' pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image' pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk' pod 'RNIap', :path => '../node_modules/react-native-iap' pod 'RNImageCropPicker', :path => '../node_modules/react-native-image-crop-picker' pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake' pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions' pod 'RNSound', :path => '../node_modules/react-native-sound' pod 'ReactNativeIncallManager', :path => '../node_modules/react-native-incall-manager' pod 'react-native-webview', :path => '../node_modules/react-native-webview' pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen' pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler' pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios' pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc' pod 'RNSVG', :path => '../node_modules/react-native-svg' pod 'CodePush', :path => '../node_modules/react-native-code-push' pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info' pod 'RNKakaoPlusFriend', :path => '../node_modules/react-native-kakao-plus-friend/ios' pod 'lottie-react-native', :path => '../node_modules/lottie-react-native' pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-community/async-storage' pod 'react-native-amplitude-analytics', :path => '../node_modules/react-native-amplitude-analytics' end ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

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`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` React Native Environment Info: System: OS: macOS 10.14.5 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 45.90 MB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 10.16.3 - /usr/local/bin/node Yarn: 1.17.3 - /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.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0 Android SDK: API Levels: 27, 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.2 System Images: android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 11.0/11A420a - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: ^0.59.6 => 0.59.10 npmGlobalPackages: react-native-cli: 2.0.1 ``` - **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:** - `v 5.2.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `N`


alizahid commented 4 years ago

Could this be related to apns-priority? iOS 13 made a few changes. This article has some useful information https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/

YoonhaHeo commented 4 years ago

I've already set both client and server side priority settings. Still doesn't work :( Thanks for the info tho

thelumiereguy commented 4 years ago

@rossenahuh Have you got it working? Even I have the same issue in iOS I'm sending data payload and it works while the app is in foreground and background but not when the app is closed. PS- It works if I send notification payload

YoonhaHeo commented 4 years ago

@rossenahuh Have you got it working? Even I have the same issue in iOS I'm sending data payload and it works while the app is in foreground and background but not when the app is closed. PS- It works if I send notification payload

I haven't figured it out. I've sent them an email and haven't got the response yet. Exactly the same on my side. Data payload - app closed in IOS / notification payload - background, app closed in Android. These two cases not working.

thelumiereguy commented 4 years ago

@rossenahuh Okay! So I kinda fixed it, in a hackish way. Now it's working in the foreground, background and when the app is closed. I fixed it by sending notification key as well as the data key like this. { "to": "", "data": { "flag": "", "image": "", "title": "Homework", "message": "Get Today's Homework Done by Tomorrow", }, "notification": { "title": "Homework", "body": "Get Today's Homework Done by Tomorrow" }, "priority": "high", "content_available": true, }

prodoxx commented 4 years ago

@thelumiereguy , did you have to set the Push Notification capabilities for iOS? Mines only work when the app is on the foreground and it doesn't work when it is on the background or closed.

The data and notification attributes do not show in my payload when the ios device receives it. It shows on android, though. I'm not if it's because I have not enabled the Push Notification capabilities for iOs.

thelumiereguy commented 4 years ago

@prodoxx I had already enabled the Push Notification capabilities, so I could not test without them. You could try enabling it maybe?

stale[bot] commented 4 years ago

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.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.