Describe your issue here
Foregound notifications on iOS was working until I updated to iOS13. Now, only background notifications work. No changes was done to my code after updating to iOS 13. All perfect on Android.
This is how I am listening for notfications:
firebase.messaging().onMessage(message => { ...code... }
It is not just that the notification is not displayed, but the onMessage listener never gets called.
Click To Expand
#### `package.json`:
{
"name": "AppName",
"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": {
"@dudigital/react-native-zoomable-view": "^1.0.15",
"@react-native-community/async-storage": "^1.5.0",
"@react-native-community/cameraroll": "^1.3.0",
"@react-native-community/netinfo": "^5.0.1",
"@terrylinla/react-native-sketch-canvas": "^0.8.0",
"axios": "^0.19.0",
"lodash": "^4.17.15",
"react": "^16.12.0",
"react-native": "^0.61.5",
"react-native-af-video-player": "^0.2.1",
"react-native-animatable": "^1.3.3",
"react-native-animated-linear-gradient": "^1.2.0",
"react-native-audio": "^4.3.0",
"react-native-cached-image": "^1.4.3",
"react-native-camera": "^3.15.0",
"react-native-collapsible": "^1.5.1",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-datepicker": "^1.7.2",
"react-native-device-info": "^2.1.2",
"react-native-fast-image": "^7.0.2",
"react-native-fetch-blob": "^0.10.8",
"react-native-firebase": "^5.6.0",
"react-native-fs": "^2.16.2",
"react-native-gallery-manager": "^1.0.9",
"react-native-gesture-handler": "^1.5.2",
"react-native-gifted-chat": "^0.7.3",
"react-native-google-places-autocomplete": "^1.4.0",
"react-native-image-pan-zoom": "^2.1.11",
"react-native-image-resizer": "^1.1.0",
"react-native-interactions": "^0.4.0",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-keep-awake": "^4.0.0",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-keychain": "^4.0.4",
"react-native-linear-gradient": "^2.5.6",
"react-native-mime-types": "^2.2.1",
"react-native-modal": "^11.5.3",
"react-native-navigation-bar-color": "^1.0.0",
"react-native-orientation": "^3.1.3",
"react-native-permissions": "^2.0.8",
"react-native-rate": "^1.1.10",
"react-native-reanimated": "^1.4.0",
"react-native-responsive-screen": "^1.3.0",
"react-native-scalable-image": "^1.0.0",
"react-native-screens": "^2.0.0-alpha.22",
"react-native-shadow": "^1.2.2",
"react-native-share": "^2.0.0",
"react-native-smooth-pincode-input": "^1.0.9",
"react-native-sound": "^0.11.0",
"react-native-splash-screen": "^3.2.0",
"react-native-store-photos-album": "^0.1.2",
"react-native-svg": "^9.13.6",
"react-native-swift": "^1.2.2",
"react-native-thumbnail": "^1.1.3",
"react-native-vector-icons": "^6.5.0",
"react-native-video": "^5.0.2",
"react-native-video-cache": "^1.0.0",
"react-native-webview": "^8.0.1",
"react-native-youtube": "^2.0.0",
"react-navigation": "^4.0.10",
"react-navigation-collapsible": "^3.0.3",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.6.2",
"react-navigation-transitions": "^1.0.12",
"react-redux": "^7.1.3",
"redux": "^4.0.4",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/runtime": "^7.7.7",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "^0.54.1",
"react-test-renderer": "^16.12.0"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./assets/fonts"
]
},
"isSwift": true
}
#### `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:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
# use_modular_headers!
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', :modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Messaging'
pod 'Firebase/Database'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
target 'ShareExtension' do
pod 'SimpleKeychain',:modular_headers => true
pod 'SwiftyJSON'
pod 'Alamofire'
pod 'SDWebImage',:modular_headers => true
end
target 'AppNameTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
end
#### `AppDelegate.m`:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import <RNFirebaseNotifications.h>
#import "RNFirebaseMessaging.h"
#import "RNSplashScreen.h"
#import <os/log.h>
#import <React/RCTLinkingManager.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[RNFirebaseNotifications configure];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"AppName"
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];
[RNSplashScreen show];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
- (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];
}
@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.2
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 190.98 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /usr/local/bin/node
Yarn: 1.16.0 - /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.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: ^16.12.0 => 16.12.0
react-native: ^0.61.5 => 0.61.5
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:**
- 5.6.0
- **`Firebase` module(s) you're using that has the issue:**
- `Notifications/Message`
- **Are you using `TypeScript`?**
- N
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase and Invertase on Twitter for updates on the library.Fixed the issue.
[application registerForRemoteNotifications]; needs to be added in appDelegate.m inside didFinishLaunchingWithOptions after [RNFirebaseNotifications configure];.
Please, add it to the docs to help other people. I have seen others also facing the same issue on iOS 13.
The documentation pages all have an edit link at the top right, github makes it easy to submit PRs
Actually it seems adding that line of code was kind of a random fix, today foreground notifications are working (without that line of code), but background are not :/
Also, a weird thing is happening is that the background notifications are actually received after opening the app. They are not received while it is closed.
Do you know any possible fix?
Isn't there a function for this, however? Its in the docs
https://invertase.io/oss/react-native-firebase/v6/messaging/reference/module#registerForRemoteNotifications
Or am I missing something?
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.
This has been fixed in #3339 - please check out the RC - 6.4.0-rc4
Most helpful comment
Fixed the issue.
[application registerForRemoteNotifications];needs to be added in appDelegate.m inside didFinishLaunchingWithOptions after[RNFirebaseNotifications configure];.Please, add it to the docs to help other people. I have seen others also facing the same issue on iOS 13.