Android上未显示OneSignal-Pushnotification小图标 [英] OneSignal-Pushnotification small icon not displayed on Android

查看:179
本文介绍了Android上未显示OneSignal-Pushnotification小图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Cordova-App,它在每个drawable-xy文件夹中都包含一个文件"icon.png".我们使用OneSignal提供推送通知.通知按预期方式工作.除了小图标.手机顶部栏上只有一个空白图标,其中显示了应用程序符号.我尝试使用以下代码段:

We have a Cordova-App which contains a file 'icon.png' in every drawable-xy folder. We provide push notifications using OneSignal. The notifications are working as expected. Except the small icon. There is only a blank icon on the top bar of my phone, where app-symbols are displayed. I tried using the following snippet:

{
   ...
   "small_icon" : "@android:drawable/icon.png"
   ....
}

我还尝试了很多其他变体,它们都没有"android",没有"drawable",没有斜线,.png和.png.等.

I also tried lots and lots of other variations without "android", without "drawable", without slash, with .png and without .png. etc. etc.

我在文档中找到了这个:( https://documentation.onesignal.com/reference#创建通知)

I found this in the documentation: (https://documentation.onesignal.com/reference#create-notification)

small_icon: stringOptional
Specific Android icon to use. If blank the app icon is used. Must be the drawable resource name.

Android讲述了可绘制资源:( https://developer.android .com/guide/topics/resources/drawable-resource.html )

Android tells about drawable resources: (https://developer.android.com/guide/topics/resources/drawable-resource.html)

将图像保存在res/drawable/myimage.png中,此布局XML会将图像应用于视图:

With an image saved at res/drawable/myimage.png, this layout XML applies the image to a View:

<ImageView
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:src="@drawable/myimage" />

对我来说应该是@drawable/icon. (不起作用)

which should be @drawable/icon for me then. (does not work)

将大图标更改为url对我来说有效,带有可绘制对象的大图标也不行.

Changing the large icon to an url works for me, large icon with a drawable does not, aswell.

此属性small_icon的正确用法是什么?

What is the correct usage of this property small_icon?

推荐答案

在Android SDK API 21之后,您的小图标必须是这样

After Android SDK API 21,your small icon must be like this

仅白色和透明.

因此,您可以对此进行编码.

So, you can code this.

if(android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.LOLLIPOP){
        notificationBuilder.setSmallIcon(R.drawable.ic_aphla_logo);
    } else {
        notificationBuilder.setSmallIcon(R.drawable.ic_logo);
    }

这篇关于Android上未显示OneSignal-Pushnotification小图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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