NativeScript / NativeScript/firebase
'No APNS token specified' error getting token on iOS
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 62
- Forks
- 53
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 2
Description
I have an issue using this plugin on iOS. I receive this error when trying to get Firebase token:
No APNS token specified before fetching FCM Token
I put GoogleService-Info.plist and app.entitlements in app/App_Resources/iOS as described in the documentation
I tried both with xcode 14.3.1 and 15.0-beta
these are the dependencies in package.json:
@nativescript/ios: 8.5.2
@nativescript/types: 8.5.0
@nativescript/core: 8.5.5
@nativescript/firebase-core: 3.1.0
@nativescript/firebase-messaging: 3.1.0
And this is the function called when the application is started:
async function firebaseInitialization() {
console.log("firebaseInitialization: start firebase registering");
const defaultApp = await firebase().initializeApp();
console.log("firebase initialized");
console.log("request for permission");
const enabled = await requestUserPermission()
try {
if (enabled) {
firebase().messaging().showNotificationsWhenInForeground = true
console.log("trying to get current token")
const token = await firebase().messaging().getToken()
console.log("current token: " + token)
//rest of the code
...
}
} catch (e) {
console.log("ERROR: " + e) //<-- the error is catched here
}
}
async function requestUserPermission() {
const authStatus = await firebase()
.messaging()
.requestPermission({
ios: {
alert: true,
},
});
const enabled = authStatus === AuthorizationStatus.AUTHORIZED || authStatus === AuthorizationStatus.PROVISIONAL;
if (enabled) {
console.log('Push notification authorized')
const didRegister = await firebase().messaging()
.registerDeviceForRemoteMessages();
return true
} else {
console.log('Push notification NOT authorized')
return false
}
}
This is the console output:
firbaseInitialization: start firebase registering
firebase initialized
request for permission
Push notification authorized
trying to get current token
ERROR: Error: No APNS token specified before fetching FCM Token
I seem to have done everything that is requested in the documentation. Any idea?
EDIT:
I tried to wrap the registerDeviceForRemoteMessages call in a try-catch statement. No exception is thrown, but after that, the registration status, checked with firebase().messaging().isDeviceRegisteredForRemoteMessages, is false
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the firebase().messaging().registerDeviceForRemoteMessages() and getToken() calls in the reported firebaseInitialization flow, using the documented GoogleService-Info.plist and app.entitlements setup as context. Check why isDeviceRegisteredForRemoteMessages remains false on iOS. Done means device registration succeeds and getToken() returns an FCM token without the APNS-token error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- firebase, ios, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100