【问题标题】:Default push-notification white square before app is loaded加载应用程序之前的默认推送通知白色方块
【发布时间】:2019-05-14 10:32:12
【问题描述】:

我已成功在 Android 上设置 phonegap-push-plugin - 我能够接收来自 FCM 的消息。当我启动应用程序并收到一条消息时,我的自定义图标会显示在状态栏中..太棒了!

但是,当应用程序尚未启动并收到消息时,图标默认返回白色方块。

插件:

phonegap-version cli 8.0.0
phonegap-plugin-push v2.1.3

应用启动时使用的代码:

const push =  PushNotification.init({
    android: {
        senderID: "418827009056", 
        sound: "true",
        vibrate: "true",
        icon: "notification",
        iconColor: "#002060",
        clearBadge : true,
    },
    browser: {
        pushServiceURL: 'http://push.api.phonegap.com/v1/push'
    },
    ios: {
        alert: "true",
        badge: "true",
        sound: "true"
    },
    windows: {}
  });

config.xml 中是否有办法为推送通知添加默认图标但应用程序已启动?

【问题讨论】:

  • 你在icon: "notification"中提到的名字必须与android图标名称相同
  • 可能..但是如何在 config.xml 文件中设置我的自定义图标?

标签: android push-notification icons phonegap


【解决方案1】:

AndroidManifest.xml中使用此代码:

<application>
    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/ic_notification" />
<application />

如 FCM android 文档中所述,如果您不需要在通知响应中发送图标名称或获取名称有困难。

【讨论】:

  • 在我们可以从任何其他 xml 文件中指定通知图标之前,我从未见过这个!
猜你喜欢
  • 2018-05-26
  • 2018-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-18
  • 2023-03-27
  • 1970-01-01
  • 2015-08-28
相关资源
最近更新 更多