【问题标题】:Firebase push notification not delivered if device is idle for few minutes and no charging state如果设备空闲几分钟且没有充电状态,则未发送 Firebase 推送通知
【发布时间】:2021-11-20 23:52:47
【问题描述】:

Firebase 推送通知适用于所有三种应用状态:前台、后台、已终止。

但如果设备空闲几分钟且没有充电状态,则不会发送通知。 但是,无论空闲时间多长,充电推送通知都有效。

我试过了:

  1. 禁用“省电模式”。

  2. 禁用“自适应省电模式”。

  3. 应用的电池优化。

  4. 在清单中添加

    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    
  5. 中移除 [android:exported="false"]
    <service
         android:name="firebase.MyFirebaseMessagingService" =>[android:exported="false"]>
         <intent-filter>
                 <action android:name="com.google.firebase.MESSAGING_EVENT" />
         </intent-filter>
     </service>
    
{
    "registration_ids": [
        "ei0....ySI"
    ],
    "data": {
       "priority" : "high",
        "title": "msg title",
        "body": "msg body"
    },
    "android": {
        "priority": "high"
    },
    "apns": {
        "headers": {
            "apns-priority": "10"
        }
    },
    "webpush": {
        "headers": {
            "Urgency": "high"
        }
    }
}

【问题讨论】:

  • 推送通知不保证即时交付
  • 正如其描述所说,python-idle 标签用于 Python 语言的 IDLE IDE。

标签: android firebase push-notification firebase-cloud-messaging


【解决方案1】:

"priority": "high" 移动到根目录有效。 现在有效载荷是这样的:

{
    "registration_ids": ["cWy......FrN"],
    "data": {
        "title": "this is msg title",
        "body": "this is msg body"
    },
    "priority": "high"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    • 2017-10-04
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-28
    相关资源
    最近更新 更多