[英]Communication Timeout Disconnect status 8 after Notifications Enabled (Android 7.1.2)
[英]Capacitor - floating notifications not enabled by default on Android after migration from cordova
我們將我們的應用程序從 Cordova 遷移到 Capacitor。
對於 Cordova 上的推送通知,我們使用了cordova-plugin-firebasex插件。
對於 Capacitor,用官方的Push Notifications插件和FCM插件(我們需要 FCM)替換了 Plugin。
現在在 Android 上安裝應用程序時,應用程序的“浮動通知”設置默認禁用,而cordova 插件默認啟用。
任何想法可能是什么原因或我們如何默認啟用設置?
普遍的共識是這個設置不受應用程序的影響,但為什么它適用於cordova-plugin?
發現區別:
如此處所述,Android 需要至少訂閱一個頻道。 cordova-plugin 會自動執行此操作,對於電容器,必須手動完成。
所以添加
await PushNotifications.createChannel({
id: '<id>',
name: '<Name>',
description: '<Description>',
importance: 5,
visibility: 1,
lights: true,
vibration: true,
});
安卓注冊后。
另外將以下作為 xml 文件放入res/values
。
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="default_notification_channel_id"><id></string>
<string name="default_notification_channel_name"><name></string>
</resources>
然后這必須在AndroidManifest.xml
鏈接:
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_name"
android:value="@string/default_notification_channel_name"/>
對於<id>
最容易使用在cordova-plugin中使用的默認id:
fcm_default_channel
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.