Below is the steps implemented in React Native code –
Do i have to add any steps or methods in iOS side?
Certificate is APNS enable.
Step 1:
# Install & setup the app module
yarn add @react-native-firebase/app
# Install the messaging module
yarn add @react-native-firebase/messaging
# If you're developing your app using iOS, run this command
cd ios/ && pod install
const getDeviceToken = firebase.messaging().getAPNSToken();
if (getDeviceToken) {
console.log('getDeviceToken:', getDeviceToken);
}
But the result i am getting in console is : { _U: 0, _V: 0, _W: null, _X: null }
Note: I am running the project in Actual iOS device.
Notification permission is already granted.
2
Answers
You need to make it async in order to wait for the token to be fetched from firebase
use
async
await
and it will workfirebase.messaging().getAPNSToken() returns a promise.
You can get your token when the promise is reloved like this: