android - 无法为 Android/IOS 应用程序 Ionic 检索 Firebase 云的 FCM 令牌
问题描述
我正在构建一个 Ionic Android/IOS 应用程序,其中包括来自 firebase 云消息传递的推送通知。但是,我在检索令牌时遇到问题。
我尝试了几种变体,但它们都会导致错误。
...
import { FCM } from '@ionic-native/fcm/ngx';
import { AngularFireMessaging } from '@angular/fire/messaging';
import { Firebase } from '@ionic-native/firebase/ngx';
@Injectable()
export class FcmNotificationProvider {
constructor(
public firebaseNative : Firebase,
public afs: AngularFirestore,
public afMessaging : AngularFireMessaging,
private platform: Platform,
private fcm: FCM
) {}
getToken() {
this.fcm.getToken
.subscribe(
(token) => { alert('We got a token', token); },
(error) => { alert(error); },
);
}}
// gives an error
Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
在我的 android 设备上运行时,我也尝试使用AngularFireMessaging
并得到不同的错误。
this.afMessaging.getToken
.subscribe(
(token) => { alert('We got a token', token); },
(error) => { alert(error); },
);
当我在我的设备上安装并运行 apk 时,出现以下错误: "This browser doesnt support the API's required to use the firebase SDK. (messaging/unsupported-browser).
关于我在这里做错了什么的任何想法?
解决方案
推荐阅读
- angular - Angular 2 - __generator 未定义
- drools - 有没有办法在 drools 中调用 void 函数?
- android - 无法使用 Nearby.Messages [Android] 发布消息
- sql - SAS First.Variable 操作的 Oracle 等效项
- json - 我正在努力解决“对象作为 React 子项无效”错误
- php - 从 php 中的多个 HTML 对象获取数据值
- python - 当函数执行 Django 时如何重定向到同一页面
- python - EAFP和mypy可以共存吗?
- c++ - 以不区分大小写的方式制作 clang 格式的订单
- javascript - Angular 7 High Charts Stock Chart Datetime X Axis tooltip 格式独立于其他工具提示