[@nativescript/firebase-messaging-core][iOS] Notification token is regenerated after app is killed
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- ios, typescript
- Bereich
- mobile
Rechercherichtung
Beginne in main.ts und verfolge firebase().messaging().registerDeviceForRemoteMessages() und getToken() während der Initialisierung. Reproduziere den ersten und die darauffolgenden iOS-Starts, überprüfe die Paketversionen in package.json und die beiden Token-Ergebnisse. Als abgeschlossen gilt die Aufgabe, wenn Benachrichtigungen beim ersten Start funktionieren und getToken() nach dem Beenden und erneuten Starten der App stabil bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
There is a weird behavior with our app about the notification token in iOS only.
We have search everywhere to find for a fix for this issue but we didn't find anything.
When I launch the first time the app, I get the notification token with firebase().messaging().getToken(), then we save the token in our user database and send notification from our server.
The first time the app is launch, the notification are not received, it only works after killing the app and relaunch it again.
But that's not it!
After the second launch, if I kill the app and then launch it again, the token change!!
firebase().messaging().getToken() is called twice, the first one return the old token and the second one return the new token
According to firebase documentation, the token only change if the app is uninstalled or data is reset which is not the case
package.json:
{
"name": "tina",
"main": "./src/main.ts",
"version": "1.0.0",
"private": true,
"dependencies": {
"@angular/animations": "~14.3.0",
"@angular/common": "~14.3.0",
"@angular/compiler": "~14.3.0",
"@angular/core": "~14.3.0",
"@angular/forms": "~14.3.0",
"@angular/platform-browser": "~14.3.0",
"@angular/platform-browser-dynamic": "~14.3.0",
"@angular/router": "~14.3.0",
"@nativescript/angular": "^14.2.8",
"@nativescript/camera": "^5.1.1",
"@nativescript/core": "~8.5.0",
"@nativescript/firebase-core": "^2.3.4",
"@nativescript/firebase-messaging": "^2.3.4",
"@nativescript/firebase-messaging-core": "^2.3.4",
"@nativescript/geolocation": "^8.3.1",
"@nativescript/imagepicker": "^3.1.1",
"@nativescript/local-notifications": "^6.1.1",
"@nativescript/mlkit-barcode-scanning": "^2.1.0",
"@nativescript/mlkit-core": "^2.1.0",
"@nativescript/theme": "~3.0.2",
"nativescript-webview-interface": "^1.4.5",
"rxjs": "~7.5.0",
"zone.js": "~0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.2.13",
"@angular/compiler-cli": "~14.3.0",
"@nativescript/android": "8.5.0",
"@nativescript/ios": "8.6.4",
"@nativescript/types": "~8.5.0",
"@nativescript/webpack": "5.0.14",
"@ngtools/webpack": "^14.2.13",
"@types/node": "^14.18.63",
"typescript": "^4.6.2"
}
}
main.ts
import { platformNativeScript, registerElement, runNativeScriptAngularApp } from '@nativescript/angular';
import '@nativescript/firebase-messaging'
import { AppModule } from './app/app.module';
import { firebase } from '@nativescript/firebase-core';
import '@nativescript/firebase-messaging';
import { AuthorizationStatus } from '@nativescript/firebase-messaging';
import { setString } from '@nativescript/core/application-settings';
import { requestPermissions } from '@nativescript/camera';
import * as geolocation from '@nativescript/geolocation';
import { isIOS } from "@nativescript/core";
import { MLKitView } from '@nativescript/mlkit-core';
runNativeScriptAngularApp({
appModuleBootstrap: () => platformNativeScript().bootstrapModule(AppModule),
});
try {
registerElement('MLKitView', () => MLKitView);
firebase().initializeApp().then(
() => {
firebase().messaging().requestPermission({
ios: {
alert: true,
},
}).then((p) => {
if(p == AuthorizationStatus.AUTHORIZED || p == AuthorizationStatus.PROVISIONAL){
firebase().messaging().registerDeviceForRemoteMessages();
firebase().messaging().showNotificationsWhenInForeground = true;
firebase().messaging().getToken().then(token => {
setString("notificationToken", token);
})
}
}).finally(() => {
if(isIOS){
requestPermissions().finally(() => { // for camera
geolocation.isEnabled().then((isEnabled) => { //for gps
if(!isEnabled){
geolocation.enableLocationRequest(true).then(() => {
});
}
})
})
}
})
console.log("firebase.init done");
},
error => {
console.log(`firebase.init error: ${error}`);
}
);
}
catch (err) {
console.log("err in try and catch " + err);
}
Let me know if you need something else to provide.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 62
- Forks
- 53
- Ø Merge
- 8 T. 4 Std.
- Gemergte PRs (30 T.)
- 2
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/firebase
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
NativeScript/firebase#292 ·
-
Can't install package Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
NativeScript/firebase#289 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
NativeScript/firebase#288 · 4 Reaktionen ·
-
bug ios
NativeScript/firebase#287 · 1 zugewiesene Person ·
-
Uh-Oh Shazam Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
NativeScript/firebase#286 ·
Alle Issues in NativeScript/firebase
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
mksglu/context-mode#1200 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
anthropics/claude-code#96687 ·
-
good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
AOSSIE-Org/DebateAI#582 · 2 Kommentare ·