Description
Issue
Trying to get token from user.
import messaging from '@react-native-firebase/messaging';
import { registerRootComponent } from 'expo';
import React, { useEffect } from 'react';
import {
Text
} from 'react-native';
async function onAppBootstrap() {
// Register the device with FCM
console.log('A');
await messaging().registerDeviceForRemoteMessages();
console.log('B');
// Get the token
const token = await messaging().getToken();
// Save the token
console.log('TOKEN ' + token);
}
function App() {
useEffect(() => {
onAppBootstrap();
}, []);
return (
<Text>Hi</Text>
);
}
console.log('Registering root component');
registerRootComponent(App);
export default App;
When running this on iOS simulator, I get A
on the console but it never reaches B. On further debugging just calling await messaging()
seems to do enough to hang.
I see now after adding initializeApp() with credentials from firebase the following error
The operation couldn’t be completed. No APNS token specified before fetching FCM Token
Project Files
Javascript
Click To Expand
package.json
:
"@react-native-firebase/app": "^17.0.0",
"@react-native-firebase/messaging": "^17.0.0",
firebase.json
for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile
:
- I'm not using Pods
- I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m
:
// 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
:
// N/A
android/app/build.gradle
:
// N/A
android/settings.gradle
:
// N/A
MainApplication.java
:
// N/A
AndroidManifest.xml
:
<!-- N/A -->
Environment
Click To Expand
System:
OS: macOS 12.5
CPU: (10) arm64 Apple M1 Pro
Memory: 227.88 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.5.0 - /opt/homebrew/bin/node
Yarn: Not Found
npm: 9.3.1 - /opt/homebrew/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9477386
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 17.0.6 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
OUTPUT GOES HERE
- Platform that you're experiencing the issue on:
- iOS
- Android
- [x ] 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:- `"@react-native-firebase/app": "^17.0.0",
-
"@react-native-firebase/messaging": "^17.0.0",`
Firebase
module(s) you're using that has the issue:e.g. Instance ID
- Are you using
TypeScript
?Y
- 👉 Check out
React Native Firebase
andInvertase
on Twitter for updates on the library.