NativeScript / NativeScript/firebase
'No APNS token specified' error getting token on iOS
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 62
- Fork
- 53
- Merge medio
- 8g 4h
- PR unite (30g)
- 2
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando le chiamate a firebase().messaging().registerDeviceForRemoteMessages() e getToken() nel flusso firebaseInitialization segnalato, usando come contesto la configurazione documentata di GoogleService-Info.plist e app.entitlements. Verifica perché isDeviceRegisteredForRemoteMessages rimane false su iOS. L’attività è completata quando la registrazione del dispositivo riesce e getToken() restituisce un token FCM senza l’errore APNS-token.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- firebase, ios, typescript
- Ambito
- mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 28/100