[@nativescript/firebase-messaging-core][iOS] Notification token is regenerated after app is killed
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ios, typescript
- Lĩnh vực
- mobile
Hướng nghiên cứu
Bắt đầu trong main.ts và theo dõi firebase().messaging().registerDeviceForRemoteMessages() cùng getToken() trong quá trình khởi tạo. Tái hiện lần khởi chạy iOS đầu tiên và các lần khởi chạy tiếp theo, kiểm tra các phiên bản package trong package.json và hai kết quả token. Hoàn tất khi thông báo hoạt động ngay từ lần khởi chạy đầu tiên và getToken() vẫn ổn định sau khi ứng dụng bị kết thúc và khởi chạy lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 62
- Fork
- 53
- Merge trung bình
- 8 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NativeScript/firebase
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
NativeScript/firebase#292 ·
-
Can't install package Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
NativeScript/firebase#289 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
NativeScript/firebase#288 · 4 reaction ·
-
bug ios
NativeScript/firebase#287 · 1 người được giao ·
-
Uh-Oh Shazam Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
NativeScript/firebase#286 ·
Tất cả issue của NativeScript/firebase
Issue tương tự
-
[Bug]: Discord Activity titles with emoji are rejected as over 80 characters when they are not Đang mởclawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
supermomonga/zcode-acp#24 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
growthbook/growthbook#7100 ·
-
triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100