简体   繁体   English

如何在android中更改Parse push notification图标?

[英]How to change Parse push notification icon in android?

In my application i have used parse cloud code for sending push notifications to user.By default notification icon used app icon.but I want to change notification icon . 在我的应用程序中,我使用解析云代码向用户发送推送通知。默认通知图标使用了应用程序图标。但我想更改通知图标。 I used this below code in manifest xml 我在manifest xml中使用了以下代码

<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/noti_icon"/>

But the icon will not change. 但图标不会改变。 Any way to achieve this?? 有没有办法实现这个?

The official way to change the Android push notification icon when receiving push notifications using Parse, as stated in the Parse Android docs for push notifications is as follows: 使用Parse接收推送通知时更改Android推送通知图标的官方方法,如推送通知的Parse Android文档中所述,如下所示:

在此输入图像描述

IMPORTANT 重要
Make sure the image that you want to use follows the Icon Reference Chart section for Notification icons - specifically: 确保您要使用的图像遵循通知图标图标参考图表部分 - 具体来说:

They should be flat (no gradients), white and face-on perspective 它们应该是平的(没有渐变),白色和正面透视

If your icon violates one of these requirements, your icon will show as a white box. 如果您的图标违反了其中一项要求,则您的图标将显示为白色框。

In PushService , each of the setDefaultPushCallback() and subscribe() methods allows an extra parameter to specify the icon: PushService ,每个setDefaultPushCallback()subscribe()方法都允许使用额外的参数来指定图标:

PushService.setDefaultPushCallback(context, SomeActivity.class, R.drawable.customIcon)

PushService.subscribe(context, "ChannelName", SomeActivity.class, R.drawable.customIcon)

Write the line below to Manifest; 写下面的行给Manifest;

<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/pushicon"/>

Please use 88X88 white image in 96X96 canvas. 请在96X96画布中使用88X88白色图像。

Here is icon; 这是图标; It's white. 它是白色的。 (!) (!)

在此输入图像描述

Here is result 这是结果

在此输入图像描述

或者您可以在Parse.com上的“设置”下单击“图像图像”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM