IOS notification works fine until I close/open the app several times while sending notifications from the server, then the IOS device does not receive any notifications and in the server I get "notRegistered" for the fcm token. After opening/closing the app several times while the server sends notifications, suddenly it is working again and the device receives the notification.
All the notifications are Notification + Data
I saw issues on it but didn't find the solution for me.
I was tried:
FirebaseAppDelegateProxyEnabled = YES to info.plistrequestPermission() on every app loadregisterDeviceForRemoteMessages() if falseonTokenRefresh to send new token to the server when the token changedOn android everything works fine.
Click To Expand
#### `package.json`:
"@react-native-firebase/analytics": "10.4.1",
"@react-native-firebase/app": "10.4.0",
"@react-native-firebase/auth": "10.4.1",
"@react-native-firebase/messaging": "10.4.1",
"react-native": "0.62.2",
#### `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, '10.0'
require_relative '../node_modules/react-native-unimodules/cocoapods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
project 'WXGERP',
'AppStore.Debug' => :debug,
'AppStore.Release' => :release,
'Prod.Debug' => :debug,
'Prod.Release' => :release
def sharedpods
rnPrefix = "../node_modules/react-native"
# React Native and its dependencies
pod 'FBLazyVector', :path => "#{rnPrefix}/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "#{rnPrefix}/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "#{rnPrefix}/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "#{rnPrefix}/Libraries/TypeSafety"
pod 'React', :path => "#{rnPrefix}/"
pod 'React-Core', :path => "#{rnPrefix}/"
pod 'React-CoreModules', :path => "#{rnPrefix}/React/CoreModules"
pod 'React-RCTActionSheet', :path => "#{rnPrefix}/Libraries/ActionSheetIOS"
pod 'React-RCTAnimation', :path => "#{rnPrefix}/Libraries/NativeAnimation"
pod 'React-RCTBlob', :path => "#{rnPrefix}/Libraries/Blob"
pod 'React-RCTImage', :path => "#{rnPrefix}/Libraries/Image"
pod 'React-RCTLinking', :path => "#{rnPrefix}/Libraries/LinkingIOS"
pod 'React-RCTNetwork', :path => "#{rnPrefix}/Libraries/Network"
pod 'React-RCTSettings', :path => "#{rnPrefix}/Libraries/Settings"
pod 'React-RCTText', :path => "#{rnPrefix}/Libraries/Text"
pod 'React-RCTVibration', :path => "#{rnPrefix}/Libraries/Vibration"
pod 'React-Core/RCTWebSocket', :path => "#{rnPrefix}/"
pod 'React-Core/DevSupport', :path => "#{rnPrefix}/"
pod 'React-cxxreact', :path => "#{rnPrefix}/ReactCommon/cxxreact"
pod 'React-jsi', :path => "#{rnPrefix}/ReactCommon/jsi"
pod 'React-jsiexecutor', :path => "#{rnPrefix}/ReactCommon/jsiexecutor"
pod 'React-jsinspector', :path => "#{rnPrefix}/ReactCommon/jsinspector"
pod 'ReactCommon/callinvoker', :path => "#{rnPrefix}/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "#{rnPrefix}/ReactCommon"
pod 'Yoga', :path => "#{rnPrefix}/ReactCommon/yoga", :modular_headers => true
pod 'DoubleConversion', :podspec => "#{rnPrefix}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{rnPrefix}/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "#{rnPrefix}/third-party-podspecs/Folly.podspec"
# Other native modules
# Automatically detect installed unimodules
use_unimodules!(exclude: ['expo-splash-screen'])
# react-native-cli autolinking
use_native_modules!
end
target 'AppStore.WXGERP' do
sharedpods
end
target 'AppStore.Dev.WXGERP' do
sharedpods
end
target 'AppStore.Staging.WXGERP' do
sharedpods
end
#### `AppDelegate.m`:
#import "AppDelegate.h"
#import <Firebase.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTI18nUtil.h>
@interface AppDelegate () <RCTBridgeDelegate>
@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@property (nonatomic, strong) NSDictionary *launchOptions;
@end
@implementation AppDelegate
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
return [RCTLinkingManager
application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler
];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[RCTI18nUtil sharedInstance] allowRTL:YES];
@try {
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
}
@catch (NSException *exception) {
NSLog(@"[FIRApp configure]; Caught %@: %@", [exception name], [exception reason]);
}
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
self.launchOptions = launchOptions;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
#ifdef DEBUG
[self initializeReactNativeApp];
#else
EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance];
controller.delegate = self;
[controller startAndShowLaunchScreen:self.window];
#endif
[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNSplashScreen show];
return YES;
}
- (RCTBridge *)initializeReactNativeApp
{
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return bridge;
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// You can inject any extra modules that you would like here, more information at:
// https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[EXUpdatesAppController sharedInstance] launchAssetUrl];
#endif
}
- (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success
{
appController.bridge = [self initializeReactNativeApp];
}
#if RCT_DEV
- (BOOL)bridge:(RCTBridge *)bridge didNotFindModule:(NSString *)moduleName {
return YES;
}
#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:**
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 23.20 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.3.0 - ~/.nvm/versions/node/v12.3.0/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.3.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28
Build Tools: 28.0.3, 29.0.3
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_265 - /usr/bin/javac
Python: 2.7.17 - /usr/local/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
- **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:**
- `e.g. 5.4.3`
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `Y/N` & `VERSION`
React Native Firebase and Invertase on Twitter for updates on the library.You selectively include chunks of info we want, not the whole thing (package.json)
in the past this has been due to e.g. react-native-push-notifications (not our package) or some other 3rd party package trying to register new tokens each app startup, which confuses everything as it's a complicated async network process. We have never reproduced this on a clean react-native-firebase only project
If you can reproduce this on a fresh project from https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh we can reopen, but this is not reproduced in my work project at least
Hi @mikehardy,
This is my whole package.json:
`
"@decor/wrappers": "1.0.605",
"@react-native-community/async-storage": "1.12.1",
"@react-native-community/clipboard": "1.5.1",
"@react-native-community/masked-view": "0.1.10",
"@react-native-community/netinfo": "5.9.2",
"@react-native-firebase/analytics": "10.4.1",
"@react-native-firebase/app": "10.4.0",
"@react-native-firebase/auth": "10.4.1",
"@react-native-firebase/messaging": "10.4.1",
"@react-navigation/native": "5.7.4",
"@react-navigation/stack": "5.9.1",
"@sentry/react-native": "1.9.0",
"@terrylinla/react-native-sketch-canvas": "0.8.0",
"@twotalltotems/react-native-otp-input": "1.3.11",
"apollo-client": "2.6.10",
"btoa": "1.2.1",
"core-js": "3.8.0",
"expo": "38.0.10",
"expo-asset": "8.2.0",
"expo-blur": "8.2.0",
"expo-constants": "9.2.0",
"expo-device": "2.3.0",
"expo-document-picker": "8.2.1",
"expo-file-system": "9.2.0",
"expo-font": "8.3.0",
"expo-image-picker": "9.1.1",
"expo-linking": "1.0.5",
"expo-localization": "9.0.0",
"expo-permissions": "9.1.0",
"expo-screen-orientation": "2.0.0",
"expo-updates": "0.2.14",
"flatted": "2.0.2",
"hoist-non-react-statics": "3.3.2",
"i18next": "19.8.3",
"immutability-helper": "2.9.1",
"immutable": "3.8.2",
"libphonenumber-js": "1.8.5",
"lodash": "4.17.20",
"lottie-ios": "3.1.3",
"lottie-react-native": "3.4.0",
"mobx": "5.15.7",
"mobx-react": "6.1.8",
"moment": "2.29.1",
"moment-timezone": "0.5.31",
"object-hash": "2.0.3",
"object-sizeof": "1.6.1",
"patch-package": "6.2.2",
"postinstall-postinstall": "2.1.0",
"query-string": "6.13.6",
"react": "16.11.0",
"react-apollo": "3.1.5",
"react-base-hooks": "0.0.3",
"react-dom": "16.11.0",
"react-i18next": "11.7.3",
"react-native": "0.62.2",
"react-native-actionsheet": "2.4.2",
"react-native-calendars": "1.403.0",
"react-native-camera": "3.40.0",
"react-native-collapsible": "1.5.2",
"react-native-country-picker-modal": "2.0.0",
"react-native-device-info": "6.2.1",
"react-native-exception-handler": "2.10.9",
"react-native-extended-stylesheet": "0.12.0",
"react-native-fast-image": "8.3.3",
"react-native-fs": "2.16.6",
"react-native-gallery-swiper": "1.26.4",
"react-native-gesture-handler": "1.8.0",
"react-native-get-random-values": "1.5.0",
"react-native-html-to-pdf": "https://github.com/DecorWeb/react-native-html-to-pdf.git",
"react-native-htmlview": "0.15.0",
"react-native-image-resizer": "1.3.0",
"react-native-image-zoom-viewer": "^3.0.1",
"react-native-keyboard-accessory": "0.1.14",
"react-native-keyboard-aware-scroll-view": "0.9.3",
"react-native-keyboard-spacer": "0.4.1",
"react-native-linear-gradient": "2.5.6",
"react-native-loading-spinner-overlay": "1.1.0",
"react-native-logs": "2.2.1",
"react-native-material-textfield": "0.12.0",
"react-native-mmkv-storage": "0.4.2",
"react-native-modal-datetime-picker": "7.6.1",
"react-native-offline": "5.7.0",
"react-native-reanimated": "1.13.1",
"react-native-restart": "0.0.14",
"react-native-safe-area-context": "3.1.8",
"react-native-screens": "2.11.0",
"react-native-share": "3.8.5",
"react-native-shared-element": "0.7.0",
"react-native-skeleton-placeholder": "1.0.3",
"react-native-sms-retriever": "1.1.1",
"react-native-snackbar-component": "1.1.11",
"react-native-sortable-list": "0.0.23",
"react-native-splash-screen": "3.2.0",
"react-native-status-bar-height": "2.5.0",
"react-native-svg": "12.1.0",
"react-native-swipeable": "0.6.0",
"react-native-swipeout": "2.3.6",
"react-native-tab-view": "2.15.2",
"react-native-table-component": "1.2.1",
"react-native-unimodules": "0.11.0",
"react-native-v8": ">=0.62.2-patch.2",
"react-native-web": "0.11.7",
"react-native-webview": "9.4.0",
"react-navigation": "4.3.7",
"react-navigation-drawer": "2.5.1",
"react-navigation-hooks": "1.1.0",
"react-navigation-redux-helpers": "4.0.1",
"react-navigation-shared-element": "3.0.0",
"react-navigation-stack": "2.3.1",
"react-navigation-tabs": "2.8.10",
"react-offix-hooks": "0.15.5",
"react-redux": "7.2.2",
"react-router": "5.2.0",
"react-use": "11.3.2",
"redux": "4.0.5",
"redux-devtools-extension": "2.13.8",
"redux-immutable": "4.0.0",
"redux-thunk": "2.3.0",
"reselect": "4.0.0",
"rn-fetch-blob": "0.12.0",
"rn-pdf-reader-js": "4.1.1",
"sentry-expo": "2.1.2",
"striptags": "3.1.1",
"toggle-switch-react-native": "2.1.0",
"use-debounce": "3.4.3",
"v8-android-jit-nointl": "8.84.0",
"validator": "11.1.0",
"wxg-core": "file:src/modules/core"
`
May you tell me please if you familiar with the library/libraries that can cause this problem?
I mentioned the ones I was familiar with, but that's an incredible stack of libraries. I'd bet $1 you can't reproduce with only react-native-firebase in a clean app.
I can say that you should drop react-native-splash-screen immediately. Switch to react-native-bootsplash
https://github.com/crazycodeboy/react-native-splash-screen/issues/289#issuecomment-502406454
It has caused problems before.
Without a clean reproduction, this is not actionable here. It will be a non-react-native-firebase package in my experience. If you can make a clean reproduction that implicates react-native-firebase we will reopen
Most helpful comment
I mentioned the ones I was familiar with, but that's an incredible stack of libraries. I'd bet $1 you can't reproduce with only react-native-firebase in a clean app.
I can say that you should drop react-native-splash-screen immediately. Switch to react-native-bootsplash
https://github.com/crazycodeboy/react-native-splash-screen/issues/289#issuecomment-502406454
It has caused problems before.