带有 Phonegap Build 和 PushPlugin 的 Android 白色通知图标 [英] White notification icon for Android with Phonegap Build and PushPlugin

查看:27
本文介绍了带有 Phonegap Build 和 PushPlugin 的 Android 白色通知图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Adob​​e 的 Build 服务来处理 Phonegap,我想知道是否(如果可以,如何)让我的通知显示一个白色图标(正如 Google 描述的那样此处).我正在使用 PushPlugin,但我找不到有关此的任何文档.目前,我的应用仅在通知内容旁边显示启动器图标.

I'm messing around with Phonegap using Adobe's Build service and I was wondering if (and if so, how) I could make my notifications display a white icon (as Google describes here). I'm using the PushPlugin but I couldn't find any documentation on this. At the moment my app just displays the launcher icon next to the notification content.

那么有谁知道是否有某种方法可以使用 PushPlugin 启用备用通知图标,我是被启动器图标卡住了还是有其他具有此功能的插件?

So does anyone know if there's some way to enable an alternate notification icon with the PushPlugin, am I stuck with the launcher icon or is there another plugin with this feature?

谢谢!

推荐答案

新的phonegap-plugin-push" 插件对新 Lollipop 的通知图标有很好的支持.

The new "phonegap-plugin-push" plugin has excellent support for notification icons for the new Lollipop.

首先在透明图标上构建一个带有颜色的图标.根据谷歌的指南,所有通知都将在通知托盘上显示为白色.

Build an icon that has color on a transparent icon first. Per google's guidelines all notifications will display white on the notification tray.

所以构建图标,然后如下指定.icon"指定图像.

So build the icon and then specify it as follows. "icon" specifies the image.

在/platforms/android/res/drawable-RES/文件夹中放置具有适当分辨率的myicon"副本,如下所示:

Place copies of "myicon" with appropriate resolutions in /platforms/android/res/drawable-RES/ folders as follows:

   mdpi    - 22x22 area in 24x24
   hdpi    - 33x33 area in 36x36
   xhdpi   - 44x44 area in 48x48
   xxhdpi  - 66x66 area in 72x72
   xxxhdpi - 88x88 area in 96x96

现在在您的 JS 中,指定您的图标.iconColor"是可选的,当你向下滑动时会指定背景.

Now in your JS, specify your icon. The "iconColor" is optional and will specify the background when you swipe down.

var push = PushNotification.init({
    "android": {
        "senderID": "<<SENDER_ID>>",
        "icon": "myicon",
        "iconColor": "#123456"
    },

在您的推送负载中,您现在可以通过添加图像"参数来覆盖在向下滑动时指定的图标.图片可以是资源,可以引用www/image/image.png",也可以是完整的 URL.

In your push payload you can now-override the icon that is specified on swipe down by adding an "image" parameter. Image can either be a resource, it can reference "www/image/image.png", or can be a full URL.

插件文档"是非常好,我建议阅读它们.希望这对某人有用.

The "plugin docs" are excellent, I recommend reading them. Hope this is useful to somebody.

这篇关于带有 Phonegap Build 和 PushPlugin 的 Android 白色通知图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆