【问题标题】:how to change the icon/logo for the push notification in ionic 2如何在 ionic 2 中更改推送通知的图标/徽标
【发布时间】:2017-03-31 12:03:18
【问题描述】:

我能够收到推送通知,下面是我编写的代码

 let push = Push.init({
        android: {
            senderID: '907xxxxx860',
            icon: 'icon'
        },
        ios: {
            alert: 'true',
            badge: true,
            sound: 'false'
        },
        windows: {}
      });

我在 android 版本 5 中进行测试。

在我的资产文件夹中,我在此路径中有一个图像 assets/images/home/KmartLogo.png。我想要这张图片作为我的 android 徽标。

我怎样才能做到这一点。根据此文档doc,我正在尝试将icon: 'icon' 中的路径提供给icon:assets/images/home/KmartLogo.png,但它不起作用如何更改我的徽标

更新通知图片我收到

【问题讨论】:

  • 你的意思是它显示白色图标吗?如果是这样,那只是 Android 5 的特定问题,只是因为 Android 5 使用模板图标。
  • 可能你的路径错了。试试./assets/images/home/KmartLogo.png
  • 我尝试了你给我的方式我无法获得徽标@suraj
  • @Djamware 如果是这样,我们如何解决这个问题
  • 这不是问题,只需制作带有透明背景的模板图标即可。 Android 5 推送通知图标中的任何颜色都将为白色。

标签: angular ionic-framework push-notification ionic2 push


【解决方案1】:

icon 名称不应包含扩展名

Doc

用作小图标的可绘制资源的名称。名字 不应包含扩展名。

android: {
            senderID: '907xxxxx860',
            icon: './assets/images/home/KmartLogo'
        },

【讨论】:

  • 当我尝试你的答案时,我的 Visual Studio 编辑器显示了这个问题[ts] Argument of type '{ android: { senderID: string; image: string; }; ios: { alert: string; badge: true; sound: string...' is not assignable to parameter of type 'PushOptions'. Types of property 'android' are incompatible. Type '{ senderID: string; image: string; }' is not assignable to type 'AndroidPushOptions'. Object literal may only specify known properties, and 'image' does not exist in type 'AndroidPushOptions'.
  • 我仍然无法更新推送通知的图标
  • 不检查我更新的问题与我收到的通知
  • 在官方网站上,他们为图标The name of a drawable resource to use as the small-icon. The name should not include the extension. 提供了这一行,这是否意味着我只需要提供小图标,如果是这样,它应该是多大的尺寸
  • 是的,它应该很小。首先检查非常小的一个。
猜你喜欢
  • 1970-01-01
  • 2018-05-26
  • 1970-01-01
  • 1970-01-01
  • 2018-03-22
  • 1970-01-01
  • 2016-04-27
  • 1970-01-01
  • 2017-01-29
相关资源
最近更新 更多