Closed antonandreyev closed 8 months ago
Hello @antonandreyev in my case I'm getting the following error after running await messaging().getToken();, had some reports of users having issues on iOS. Then tested on simulator and got the error in version 16.2 of iOS NativeFirebaseError: [messaging/unknown] The operation couldn’t be completed. Invalid fetch response, expected 'token' or 'Error' key.
@livnunes @antonandreyev Your experience replicates for me iPhone 14 (iOS 16.0) emulator, since this morning, I'm getting the exact same error:
NativeFirebaseError: [messaging/unknown] The operation couldn’t be completed. Invalid fetch response, expected 'token' or 'Error' key
There have been no Firebase-related library changes in our RN project in the time frame in question. I did how ever run a fresh pod install this morning as part of some unrelated 3rd party library changes. Podfile.lock is unchanged w.r.t. Firebase.
For what it's worth the project is on RN 0.68.5 with RN Firebase 13.0.1.
We were in the process of looking into the RN Firebase upgrade, but need to complete our assessment of the breaking change with use_frameworks!
in RN Firebase 15.
Currently we can not replicate it in STAGING or PROD, but if this is due to some "unpinned" deep dependency that gets updated to a disfunctional/incompatible native library with the next Deployment CI run, we would have a real 🔥.
The bug stops the App cold when the user logs in, and we try to getToken()
.
@mikehardy By any chance, are you aware of anything that might have caused this sudden change "overnight"? 🙇
To clarify about my case: that didn't came overnight. We started to notice this "need to register" error a while ago. We thought we could fix that with explicitely registering and changed code to that is in the opening message. But that didn't help and now we see both "no need to register" and "you need to register". The case is quite rare though, 100 errors in 10000 sessions in past 24 hours.
@antonandreyev Thanks for the clarification and in order to keep your issue what it was meant to be, I have opened: https://github.com/invertase/react-native-firebase/issues/6830 cc @livnunes @mikehardy
Hello, the above issue could happen because of unresolved issue https://github.com/invertase/react-native-firebase/issues/5377
Please check your Podfile and if you have abstract_target
there -> that's the case. It probably skips the [RNFB] Core Configuration
script phaze during pod install
@rivaros the Podfile is attached to the issue and there is no abstract_target
in it. Also this issue is happening only to a minority of users, so I doubt this is a linking issue.
It seems much more like the actual issue is that the token fails to be fetched or firebase/messaging fails to be registered in some special cases and the error message is misleading.
@antonandreyev did not see you included Podfile. So yes, indeed your case is different.
Have noticed that you implemented didRegisterForRemoteNotificationsWithDeviceToken
. Does it play well with swizzling https://firebase.google.com/docs/cloud-messaging/ios/client#token-swizzle-disabled ?
@rivaros it does. My implementation is just a part of expo setup instructions. As I understand when swizzling is enabled (default) there is no need to change anything in didRegisterForRemoteNotificationsWithDeviceToken
. At least it does work well as per our monitoring.
Same problem here, any solutions so far ? I'm using React Native CLI.
await messaging().registerDeviceForRemoteMessages();
i got this error:
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.
if I remove registerDeviceForRemoteMessage
I got next error:
[Error: [messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages().]
@dragoshuniq one is a warning ("that it may not be necessary"), and one is an error ("you are not registered"). There are a few cases where you do actually not need to register, for example if you have AppDelegate swizzling disabled for firebase FCM or similar, and it appears you have one of them for whatever reason.
So, leave that call in.
Our user experience the same issue. It only occurs to a small group of users.
Sentry log:
device iPhone 11 Pro
device.family iOS
event.environment javascript
event.origin javascript
hermes true
os iOS 16.2
Message error_register_device with message: [messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages().
RNFirebasea version: 16.7.0
The issue first appeared Feb. 10 in our logs. In the weeks before, there has been no update to the app regarding RNFirebase.
@idlework that is a legitimate error case that must be handled now with the new strict requirement that you must have an APNS token before getting an FCM token. I am not 100% sure how many cases there are where registration for remote notifications can fail, but it is clearly possible. Perhaps a network error and a retry would work. Perhaps there is a permissions denial by the user? I'm not sure. But, if you cannot get an APNS token, an FCM token is by definition useless and those types of FCM tokens are not issued now, so this error should be handled with some messaging to the user (for example "such and such feature of our app relies on remote notifications and there was an error registering for remote notificaitons. Perhaps check such and such ...")
@mikehardy Thanks for the quick and clear answer. I'll implement a check to see what the user response is for the notifications request.
@mikehardy It might be worth chiming in that after upgrading to 17.3.1 we started getting the You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages()
error despite calling it in this order
await messaging.registerDeviceForRemoteMessages();
const token = await messaging.getToken();
But it was actually due to it being called on an iOS SIMULATOR. It might be worth noting somewhere that the new changes around this stuff seem to make simulators throw this error now. The same exact code works fine on physical devices for us.
Simulators on intel Macs will need to call setAPNSToken now, as there is no token available for them, they do not support APNS or FCM (thus, the error is real). You can set a bogus token in though, we do that for our testing purposes and confirmed via collaboration with firebase-ios-sdk this is a valid strategy: https://github.com/invertase/react-native-firebase/blob/00185a37bc554f9bcb6feb6434d6c9c75ed51a3a/packages/messaging/e2e/messaging.e2e.js#L203
Cool (in my opinion) news though: on M1 macs using latest macOS (ventura) and iOS (in simulator) the Simulator actually supports FCM/APNS - so it works! I tested that personally and cleaned out all the stuff in our code here to enable it.
Both of those things could be called out in the docs more strongly yes - if you remember what page you were on when you were referring to this documentation and got hung up, you might be the best person as I've lost all perspective - there's an edit button at the top of each page and github web UI for docs PRs is just a 1-2 minute thing. I'll shepherd it through
@mikehardy I don't think there was a particular page on the documentation, but if it's not too late I'd just add a line to the break change notice in the release notes. I was simply following that when I came across this issue. So perhaps just one line that even if you call registerDeviceForRemoteMessages before getToken it will still fail on intel simulators?
Hello @mikehardy , I got the same issue, just upgrade my react native to the latest:
@LuongTruong there are quite a few things ("issues") discussed, could you be more specific by including the actual message contents you receive, along with a minimal reproduction that would show the error if placed in an App.js? Do make sure that you have requested + received notification permission from the user, have the correct entitlements, are in an environment where you can either get an APNS token (real device, or current simulator on current macOS on Apple Silicon machine) or you have set an APNS token
Hello @mikehardy , thank you for the clear response. Actually, the warning I receive is:
You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages(). NativeFirebaseError: [messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages().
It is working good with the version:
"Do make sure that you have requested + received notification permission from the user" Yes, I did
"have the correct entitlements" Yes, the app works good before, and I make no changes to the entitlements
"you have set an APNS token" Yes, I did
But after I upgrade the react-native version and react-native-firebase, the warning appears.
FYI, it looks like the error only appear on the iOS simulator. I tried the real device and it is working good.
Hmm that is odd - we test on the simulator as our main e2e test environment. It is an x86 simulator though so now follows a different code path from M1-mac+ios16 simulators though since those may receive real APNS tokens and cloud messaging now. You might triple check that you really are registering for remote notifications with no error returned. As I was implementing the new simulator capability of receiving FCM on M1-mac+ios16 I was testing it on simulator all the time and it definitely can work.
Hello @mikehardy , thank you for the comment and sorry for the late reply.
Actually, my Mac is using the Intel Chip. Below is the code I use to get FCM token
async setupFCM(receivedPush: (title: string, body: string) => void): Promise<void> {
const granted = await messaging().requestPermission();
if (granted) {
logPush('granted messaging permissions!');
messaging().onNotificationOpenedApp(() => {
// Do something when app receive notification
});
logPush('Registered Device For Remote Messages');
const fcmToken = await messaging().getToken();
logPush('FCM Token ' + fcmToken);
// Save FCM token
messaging().onMessage(remoteMessage => {
logPush('FCM Message:' + remoteMessage);
receivedPush(remoteMessage?.data?.title || 'Message', remoteMessage?.data?.body || 'You have a new message');
});
} else {
logPush('User declined messaging permissions');
}
},
Please let me know if you see anything weird in my code. Many thanks!
You fall into this case I believe:
Simulators on intel Macs will need to call setAPNSToken now
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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Still facing this issue. Any fix?
Any fix yet?
[Error: [messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages().]
I experience this issue on iOS 14.5 device simulator. And the same code works fine on iOS 16.4 device simulator.
I experience this issue on iOS 14.5 device simulator. And the same code works fine on iOS 16.4 device simulator.
Same here. Works perfect on 16.2 iOS Simulator 16.2, but the error occurs in 13.7 iOS Simulator device.
I am getting this error as well. IOS Simulator 16.4, M2 mac.
Once I remove await messaging().registerDeviceForRemoteMessages();
it throws another warning saying device must be registered for remote messages
Is there any success? I waiting from last month
same issue on iOS simulator
Same here
Same here, still experiencing this error with intel mac, tried with getAPNSToken() and setAPNSToken(), not working. @mikehardy
I'm facing the same issue.
Any updates regarding this issue?
Any updates?
Solved it by joining Apple Developer Program, enabling notification capability and registering APN key. I believe most people who are facing this issue are not members of the Apple Developer Program.
This is happening for me as well. The getToken
call successfully executes in that it still generates a token, but it is triggering an error which is bloating our error reporting. (so we've had to add an ignore case for now)
What's interesting is that the ...You must be registered...
error only occurs on a real device. Awaiting messaging().registerDeviceForRemoteMessages().]
before calling getToken
does not resolve the error, but it does cause a new warning like others have mentioned.
@mikehardy It might be worth chiming in that after upgrading to 17.3.1 we started getting the
You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages()
error despite calling it in this orderawait messaging.registerDeviceForRemoteMessages(); const token = await messaging.getToken();
But it was actually due to it being called on an iOS SIMULATOR. It might be worth noting somewhere that the new changes around this stuff seem to make simulators throw this error now. The same exact code works fine on physical devices for us.
It's worked for my side. @marcfrankel Thanks for the quick and clear answer.
This is happening for me as well. The
getToken
call successfully executes in that it still generates a token, but it is triggering an error which is bloating our error reporting. (so we've had to add an ignore case for now)What's interesting is that the
...You must be registered...
error only occurs on a real device. Awaitingmessaging().registerDeviceForRemoteMessages().]
before callinggetToken
does not resolve the error, but it does cause a new warning like others have mentioned.
Hm, I see this error on both real devices and emulators. Tried with two iOS versions on real devices, 15.7 and 16.5. Both showing the same warning and no token is being generated. My react-native-firebase version is 17.4.3 and it works like a charm on Android devices. It's very frustrating that no one gave any insight on this bug since it's being created. @antonandreyev , did you managed to fix this issue on your side?
@feuermeister no, still happening. At the moment we're just ignoring the error message since it's happening only to a minority of users and nobody yet complained. Need to mention, that we're still on 16.x, can't say anything about latest version.
https://rnfirebase.io/messaging/usage/ios-setup Seems like there are some additional configurations needed for iOS. Since I haven't enrolled for the developer program yet, I can not tell if this can fix the issue. Have anyone tried going through the process? If not, I'll be able to test in a few days.
Edit: I also found that some of the info is bit outdated, so instead of searching for "Push notifications" capability, you should select "Background Modes" and then check "Background fetch" and "Remote notifications"
https://rnfirebase.io/messaging/usage/ios-setup Seems like there are some additional configurations needed for iOS. Since I haven't enrolled for the developer program yet, I can not tell if this can fix the issue. Have anyone tried going through the process? If not, I'll be able to test in a few days.
Edit: I also found that some of the info is bit outdated, so instead of searching for "Push notifications" capability, you should select "Background Modes" and then check "Background fetch" and "Remote notifications"
This configuration resolved my issue
Do you have any update on this ? This issue is happening in real devices too.
My Project config
"@react-native-firebase/analytics": "^17.5.0",
"@react-native-firebase/app": "^17.5.0",
"@react-native-firebase/crashlytics": "^17.5.0",
"@react-native-firebase/messaging": "^17.5.0",
"react": "^18.2.0",
"react-native": "0.70.2",
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 attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
https://rnfirebase.io/messaging/usage/ios-setup Seems like there are some additional configurations needed for iOS. Since I haven't enrolled for the developer program yet, I can not tell if this can fix the issue. Have anyone tried going through the process? If not, I'll be able to test in a few days.
Edit: I also found that some of the info is bit outdated, so instead of searching for "Push notifications" capability, you should select "Background Modes" and then check "Background fetch" and "Remote notifications"
In case useful, I can confirm that we have had Push Notifications working successfully on iOS with only the Remote Notifications
Background Mode enabled in the App Capabilities section of XCode. So from our experience the Background fetch
option does not need to be enabled in order to Push Notifications to be received by an App.
To the original error message of this ticket, we too have been seeing the "You must be registered for remote messages before calling getToken..." error reported using v12.9.3 of the RN Firebase library (with RN 0.66.5) , despite our code path appearing to ensure that getToken
is only ever called after registerDeviceForRemoteMessages
.
We are due to release an update to v18.1.0 to see if this affects the frequency of this error and will report back here with the findings.
In my case, I had switched to a new branch and I got this error. I noticed that the push notification capability was gone in Xcode. My issue was resolved after adding push notification capability again beside the Background fetch and Remote notifications mentioned above.
That's interesting thanks @sametcl2 - I see now on reading all the above comments that both @feuermeister and @Yandamuri also found that ensuring both the 'Background fetch' and 'Remote notifications' are set apparently helped to remove the "You must be registered for remote messages before calling getToken" warning.
After running into various build issues updating our react-native-firebase
version above v15 due to the requirement to enable use_frameworks
and the hermes issues detailed here (I think in part due to our now quite old RN version, 0.66.5) we will also try the simpler option of having both those values set in the App Capabilities as a stop gap, until we have updated our main react-native
version and can then hopefully get back up to date with the latest RN firebase library
Same problem here, any solutions so far ? I'm using React Native CLI.
await messaging().registerDeviceForRemoteMessages();
i got this error: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.
if I remove registerDeviceForRemoteMessage
I got next error:
[Error: [messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages().]
same here any solution ????
Issue
After
messaging().registerDeviceForRemoteMessages()
use ofmessaging().getToken()
is still throwing[messaging/unregistered] You must be registered for remote messages before calling getToken, see messaging().registerDeviceForRemoteMessages()
on iOS 16.2. Probably some older or newer versions are also affected, but not visible in my logs at the moment. If more logs will come I will update the issue.Code is simple:
UPD:
Using Sentry, here are some extractions from logs:
UPD: Sentry statistics for 48 hours:
OS: 15.6.1, 16.1.1, 16.1.2, 16.2
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "...", "version": "0.1.0", "license": "UNLICENSED", "main": "index.js", "private": true, "engineStrict": true, "engines": { "node": "16.19.0", "yarn": "1.22.17" }, "scripts": { "ios": "react-native run-ios", "web": "expo start --web", "start": "react-native start --reset-cache", "start-cached": "react-native start", "lint": "eslint . --ext .tsx,.ts", "lint:fix": "yarn lint --fix", "tsc": "tsc", "test": "jest", "test:ci": "jest --passWithNoTests --ci", "codegen": "graphql-codegen", "translation:gen": "ts-node scripts/fetch-static-translations.ts && prettier --write src/__resources__/i18n_resource.json", "prettier": "prettier --check './src/**/*.{ts,tsx,json}'", "prettier:fix": "prettier --write './**/*.{ts,tsx,json}'", "prepare": "husky install", "ci": "rm -rf node_modules && yarn install --prefer-offline --frozen-lockfile && yarn cache clean", "postinstall": "patch-package", "ios:test": "yarn detox test --configuration ios.debug", "ios:build": "yarn detox build --configuration ios.debug", "e2e:ios": "yarn ios:build && yarn ios:test", "android:test": "yarn detox test --configuration android", "android:build": "yarn detox build --configuration android", "e2e:android": "yarn android:build && yarn android:test" }, "dependencies": { "@apollo/client": "^3.7.3", "@formatjs/intl-getcanonicallocales": "^2.0.5", "@formatjs/intl-locale": "^3.0.11", "@formatjs/intl-numberformat": "^8.3.3", "@formatjs/intl-pluralrules": "^5.1.8", "@gorhom/bottom-sheet": "~4.4.5", "@react-native-async-storage/async-storage": "~1.17.11", "@react-native-clipboard/clipboard": "^1.11.1", "@react-native-community/art": "^1.2.0", "@react-native-firebase/analytics": "^16.4.6", "@react-native-firebase/app": "~16.4.6", "@react-native-firebase/messaging": "^16.4.6", "@react-native-masked-view/masked-view": "^0.2.8", "@react-navigation/bottom-tabs": "6.5.0", "@react-navigation/native": "6.1.0", "@react-navigation/stack": "6.3.8", "@sentry/react-native": "4.2.2", "accordion-collapse-react-native": "^1.1.1", "d3-scale": "^4.0.2", "date-fns": "^2.29.3", "date-fns-tz": "^1.3.7", "expo": "~46.0.17", "expo-av": "~12.0.4", "expo-constants": "~13.2.4", "expo-device": "~4.3.0", "expo-file-system": "~14.1.0", "expo-font": "~10.2.0", "expo-network": "~4.3.0", "expo-secure-store": "~11.3.0", "expo-splash-screen": "~0.16.2", "expo-updates": "~0.14.7", "expo-web-browser": "~11.0.0", "formik": "^2.2.9", "graphql": "^16.6.0", "i18next": "^22.4.9", "jwt-decode": "^3.1.2", "lodash": "^4.17.21", "lottie-react-native": "~5.1.3", "luxon": "^3.2.1", "react": "18.0.0", "react-apollo-network-status": "^5.2.1", "react-dom": "18.0.0", "react-i18next": "^12.1.4", "react-native": "0.69.7", "react-native-animatable": "^1.3.3", "react-native-calendars": "^1.1293.0", "react-native-device-info": "^10.3.0", "react-native-gesture-handler": "^2.8.0", "react-native-indicators": "^0.17.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-localize": "^2.2.4", "react-native-media-query": "^2.0.0", "react-native-reanimated": "~2.13.0", "react-native-safe-area-context": "^4.4.1", "react-native-screens": "^3.18.2", "react-native-share": "^8.0.0", "react-native-skeleton-placeholder": "5.2.4", "react-native-svg": "^13.6.0", "react-native-url-polyfill": "^1.3.0", "react-native-view-pdf": "^0.14.0", "sentry-expo": "^5.0.3", "styled-components": "~5.3.6", "victory-core": "~36.6.8", "victory-native": "~36.6.8", "victory-tooltip": "~36.6.8", "yup": "^0.32.11", "zod": "^3.20.2" }, "devDependencies": { "@babel/core": "~7.20.12", "@babel/plugin-syntax-flow": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.20.7", "@babel/preset-typescript": "~7.18.6", "@expo/config": "^7.0.3", "@graphql-codegen/cli": "^2.16.3", "@graphql-codegen/near-operation-file-preset": "^2.5.0", "@graphql-codegen/schema-ast": "^2.6.1", "@graphql-codegen/typescript-operations": "^2.5.12", "@graphql-codegen/typescript-react-apollo": "~3.3.7", "@testing-library/react-native": "^10.1.1", "@tsconfig/node16": "^1.0.3", "@types/d3-scale": "^4.0.3", "@types/jest": "^27.5.2", "@types/luxon": "^3.2.0", "@types/node": "^17.0.45", "@types/react": "~18.0.26", "@types/react-native": "~0.69.16", "@types/xml2js": "^0.4.11", "@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/parser": "^5.48.1", "@xtrctio/eslint-plugin-disallow-date": "^1.0.1", "babel-preset-expo": "^9.2.2", "cross-fetch": "^3.1.5", "detox": "^20.1.1", "eslint": "^8.31.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-prettier": "^8.6.0", "eslint-config-react-app": "^7.0.1", "eslint-loader": "^4.0.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.7.0", "eslint-plugin-react": "^7.31.11", "eslint-plugin-react-hooks": "^4.3.0", "expo-cli": "^6.0.8", "graphql-tag": "^2.12.6", "husky": "^8.0.3", "import-sort-style-eslint": "^6.0.0", "jest": "27.5.1", "jest-junit": "^15.0.0", "lint-staged": "^13.1.0", "patch-package": "^6.5.1", "prettier": "2.8.2", "prettier-plugin-import-sort": "^0.0.7", "react-native-dotenv": "^3.4.6", "react-test-renderer": "18.0.0", "ts-node": "^10.9.1", "typescript": "~4.9.4" }, "importSort": { ".js, .jsx, .ts, .tsx": { "style": "eslint", "parser": "typescript" } }, "lint-staged": { "**/*.ts?(x)": [ "eslint", "prettier --write" ] } } ``` #### `firebase.json` for react-native-firebase v6: (no firebase.json) ```json # N/A ```
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking") require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods") require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules") platform :ios, '12.4' install! 'cocoapods', :deterministic_uuids => false production = ENV["PRODUCTION"] == "1" require 'json' podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {} target '...' do use_expo_modules! post_integrate do |installer| begin expo_patch_react_imports!(installer) rescue => e Pod::UI.warn e end end config = use_native_modules! config = use_frameworks! :linkage => :static # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config["reactNativePath"], :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes', :production => production, :fabric_enabled => flags[:fabric_enabled], # disable due to use_frameworks needed by firebase :flipper_configuration => FlipperConfiguration.disabled, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) pod 'Firebase/Analytics' post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
#import
#import
#import
#import
#import
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RCTAppSetupPrepareApp(application);
[FIRApp configure];
RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
NSDictionary *initProps = [self prepareInitialProps];
UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"main" initialProperties:nil];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [self.reactDelegate createRootViewController];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[super application:application didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (NSDictionary *)prepareInitialProps
{
NSMutableDictionary *initProps = [NSMutableDictionary new];
return initProps;
}
- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge
{
// If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here!
return @[];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#ifdef DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options {
return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
}
// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler {
BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
@end
```
Android
Click To Expand
N/A
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: Windows 10 10.0.22621 CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H Memory: 9.29 GB / 31.68 GB Binaries: Node: 16.19.0 - C:\Users\ANTON~1.AND\AppData\Local\Temp\yarn--1673424499379-0.7430549663942487\node.CMD Yarn: 1.22.17 - C:\Users\ANTON~1.AND\AppData\Local\Temp\yarn--1673424499379-0.7430549663942487\yarn.CMD npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels: 27, 30, 31, 33 Build Tools: 27.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.0 System Images: android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64 Android NDK: Not Found Windows SDK: Not Found IDEs: Android Studio: Not Found Visual Studio: Not Found Languages: Java: 11.0.15 npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.7 => 0.69.7 react-native-windows: 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:** - `16.4.6` - **`Firebase` module(s) you're using that has the issue:** - `messaging` - **Are you using `TypeScript`?** - `Y` & `4.9.4`