Issue
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"
....
}
I also tried lots and lots of other variations without "android", without "drawable", without slash, with .png and without .png. etc. etc.
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 tells about drawable resources: (https://developer.android.com/guide/topics/resources/drawable-resource.html)
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" />
which should be @drawable/icon
for me then. (does not work)
Changing the large icon to an url works for me, large icon with a drawable does not, aswell.
What is the correct usage of this property small_icon
?
Solution
After Android SDK API 21,your small icon must be like this
white and transparent only.
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);
}
Answered By - kidyu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.