Android Notification Icon is not working

I am having the same issue as this thread:

https://forums.coronalabs.com/topic/73717-android-push-notification-icons-not-showing/

I added all the notification icon below:

IconNotificationDefault-ldpi.png 18 × 18

IconNotificationDefault-mdpi.png 24 × 24

IconNotificationDefault-hdpi.png 36 × 36

IconNotificationDefault-xhdpi.png 48 × 48

IconNotificationDefault-xxhdpi.png 72 × 72

IconNotificationDefault-xxxhdpi.png 96 × 96

 

When I receive a local notification, it only shows up a white blank square icon.

 

Is this a bug or I did something wrong? I saw the thread has been closed but without any solution.

anyone?

Hello. I started the thread you linked and I sent a bug report back then.

Even though it says in the thread that it was in the pipeline… it was never fixed.

We get complaints from our Android users about this on a regular basis, so it is kind of disappointing that the bug was never taken more serious.

It is an Android only problem and I seem to remember that the notification icons did work on local push, so you might be facing a different problem.

Notification is working for me (Android & iOS). On Android, all my icons works fine.

I notice there are some differences in the file naming and sizes. I think it is from the legacy-naming-method.  I am using the FCM (notifications-v2)  @ http://docs.coronalabs.com/plugin/notifications-v2/index.html

Here’s mine with the zip file.

IconNotificationDefault-xxhdpi.png (75x75) IconNotificationDefault-xxhdpi-v11.png (72x72) IconNotificationDefault-xxxhdpi.png (96x96) IconNotificationDefault-xxxhdpi-v11.png (96x96) IconNotificationDefault-xxxxhdpi.png (120x120) IconNotificationDefault-xxxxhdpi-v11.png (120x120) IconNotificationDefault-hdpi.png (38x38) IconNotificationDefault-hdpi-v11.png (36x36) IconNotificationDefault-ldpi.png (18x18) IconNotificationDefault-mdpi.png (24x24) IconNotificationDefault-mdpi-v11.png (24x24) IconNotificationDefault-xhdpi.png (48x48) IconNotificationDefault-xhdpi-v11.png (48x48)

@yosu

Very strange. I just built my app with your icons and it is not working on my test device.

I am also using the notifications-v2 plugin with FCM.

Did you test it on multiple devices with different versions of Android OS?

I use them on android  4, 6, 9 (latest on samsung note9) on several devices. They all work fine.

Ensure the ‘useGoogleServicesJson=true’ and also i left in some extra permissions (old GCM related).

Here is part of my build.settings file (formatting a bit messed up).

 plugins = { ["plugin.openssl"] = { publisherId = "com.coronalabs", }, -- ["plugin.notifications"] = { publisherId = "com.coronalabs" }, -- old GCM http://coronalabs.com/blog/2015/01/21/notifications-have-been-moved-to-a-plugin/ ["plugin.notifications.v2"] = { publisherId = "com.coronalabs" }, -- FCM ! ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs" }, -- in-app purchase for Google ["CoronaProvider.native.popup.social"] = { publisherId = "com.coronalabs" }, -- corona show-popup / Sharing -- ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, -- AdMob -- ["facebook"] = { publisherId = "com.coronalabs" }, -- facebook -- ["plugin.facebook.v4"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, android=true, ["android-kindle"]=true } }, -- facebook-v4 -- ["plugin.facebook.v4a"] = { publisherId = "com.coronalabs" }, }, build = { -- neverStripDebugInfo = false }, excludeFiles = { -- Exclude all files at paths which end with "secret.txt": -- all = { "\*secret.txt" }, -- Exclude all Android icon files and .ogg files in the "music" directory: -- iphone = { "Icon-\*dpi.png", "music/\*.ogg" }, -- Exclude iOS "retina" image files and .m4a files in the "music" directory: android = { -- "asset/\*/\*@4x.png", -- "asset/\*/\*@4x.jpg", "Default-568h@2x.png", "Default-667h@2x.png", "Default-736h@3x.png", "Default-Landscape-568h@2x.png", "Default-Landscape-667h@2x.png", "Default-Landscape-736h@3x.png", "Default-Portrait@2x.png", "Default-Landscape@2x.png", -- "AppIcon\*", -- "iTunesArtwork\*", } }, android = { -- minSdkVersion = "11", -- Android 3.0.x, http://developer.android.com/guide/topics/manifest/uses-sdk-element.html -- coronaWindowMovesWhenKeyboardAppears = true, CoronaWindowMovesWhenKeyboardAppears = true, useGoogleServicesJson = true, permissions = { { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" }, }, usesPermissions = { "com.android.vending.BILLING", -- in-app purchase -- "android.permission.READ\_PHONE\_STATE", -- "android.permission.VIBRATE", "android.permission.INTERNET", -- "android.permission.GET\_ACCOUNTS", -- For GCM push-notification -- "android.permission.RECEIVE\_BOOT\_COMPLETED", -- For GCM push-notification -- "com.google.android.c2dm.permission.RECEIVE", -- For GCM push-notification -- ".permission.C2D\_MESSAGE", -- For GCM push-notification -- "android.permission.ACCESS\_FINE\_LOCATION", -- "android.permission.ACCESS\_COARSE\_LOCATION", -- "android.permission.STORAGE", -- "android.permission.CAMERA", "android.permission.READ\_EXTERNAL\_STORAGE", -- to access photo gallery -- "android.permission.WRITE\_EXTERNAL\_STORAGE", -- Used in full version, to upload photo }, usesFeatures = { -- If you set permissions "ACCESS\_FINE\_LOCATION" and "ACCESS\_COARSE\_LOCATION" above, -- then you may want to set up your app to not require location services as follows. -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable -- to purchase this app in the app store. }, },

I am pretty sure there are no errors in my build file.

When did you do the build that shows the notification icons?

I am wondering if you did the build before it broke.

Corona Labs wrote the bug fix was in the pipeline back then, so I guess they could reproduce the bug I reported.

I have been using them since 2018 with random daily builds. Works fine.

And now I am using build 2019.3474

Maybe you can attach your icons here for me to try out on my app.

Hey yosu

Very nice of you. I will PM the icons.

Thanks

@yosu I have no idea why this would work for you. As far as I can see it is a bug from coronas side… but I finally found a solution.

After extracting and inspecting the AndroidManifest.xml from the apk I finally figured out what the problem is.

Apparently the build process doesn’t point firebase to the correct notification icon resource path.

Adding this entry to the android build.settings fixed the problem.

android = { applicationChildElements = &nbsp; &nbsp; &nbsp; &nbsp; { [[\<meta-data android:name="com.google.firebase.messaging.default\_notification\_icon" android:resource="@drawable/corona\_statusbar\_icon\_default"/\>]] &nbsp; &nbsp; &nbsp; &nbsp; }, } }

And by the way this one still needs to be fixed: https://forums.coronalabs.com/topic/71552-notificationscancelnotification-not-working/

The other topic about cancelling notification is closed and no one can reply. My notification cancellation works (especially remote notification as I use them and cancel them too).  For this case it was tested and used on several devices like Android 4, Android 6, and 9.

Local and remote notification on my android device is cleared. What android device are you using ?

local object = display.newText( "Clear Notifications", display.contentCenterX, display.contentCenterY, native.systemFont, 25 ) local function onObjectTouch( event ) if ( event.phase == "began" ) then -- print( "Touch event began on: " .. event.target.id ) elseif ( event.phase == "ended" ) then -- print( "Touch event ended on: " .. event.target.id ) print( 'Cancelling Notifications...') g\_notifications.cancelNotification() end return true end object:addEventListener( "touch", onObjectTouch )

anyone?

Hello. I started the thread you linked and I sent a bug report back then.

Even though it says in the thread that it was in the pipeline… it was never fixed.

We get complaints from our Android users about this on a regular basis, so it is kind of disappointing that the bug was never taken more serious.

It is an Android only problem and I seem to remember that the notification icons did work on local push, so you might be facing a different problem.

Notification is working for me (Android & iOS). On Android, all my icons works fine.

I notice there are some differences in the file naming and sizes. I think it is from the legacy-naming-method.  I am using the FCM (notifications-v2)  @ http://docs.coronalabs.com/plugin/notifications-v2/index.html

Here’s mine with the zip file.

IconNotificationDefault-xxhdpi.png (75x75) IconNotificationDefault-xxhdpi-v11.png (72x72) IconNotificationDefault-xxxhdpi.png (96x96) IconNotificationDefault-xxxhdpi-v11.png (96x96) IconNotificationDefault-xxxxhdpi.png (120x120) IconNotificationDefault-xxxxhdpi-v11.png (120x120) IconNotificationDefault-hdpi.png (38x38) IconNotificationDefault-hdpi-v11.png (36x36) IconNotificationDefault-ldpi.png (18x18) IconNotificationDefault-mdpi.png (24x24) IconNotificationDefault-mdpi-v11.png (24x24) IconNotificationDefault-xhdpi.png (48x48) IconNotificationDefault-xhdpi-v11.png (48x48)

@yosu

Very strange. I just built my app with your icons and it is not working on my test device.

I am also using the notifications-v2 plugin with FCM.

Did you test it on multiple devices with different versions of Android OS?

I use them on android  4, 6, 9 (latest on samsung note9) on several devices. They all work fine.

Ensure the ‘useGoogleServicesJson=true’ and also i left in some extra permissions (old GCM related).

Here is part of my build.settings file (formatting a bit messed up).

 plugins = { ["plugin.openssl"] = { publisherId = "com.coronalabs", }, -- ["plugin.notifications"] = { publisherId = "com.coronalabs" }, -- old GCM http://coronalabs.com/blog/2015/01/21/notifications-have-been-moved-to-a-plugin/ ["plugin.notifications.v2"] = { publisherId = "com.coronalabs" }, -- FCM ! ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs" }, -- in-app purchase for Google ["CoronaProvider.native.popup.social"] = { publisherId = "com.coronalabs" }, -- corona show-popup / Sharing -- ["plugin.google.play.services"] = { publisherId = "com.coronalabs" }, -- AdMob -- ["facebook"] = { publisherId = "com.coronalabs" }, -- facebook -- ["plugin.facebook.v4"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, android=true, ["android-kindle"]=true } }, -- facebook-v4 -- ["plugin.facebook.v4a"] = { publisherId = "com.coronalabs" }, }, build = { -- neverStripDebugInfo = false }, excludeFiles = { -- Exclude all files at paths which end with "secret.txt": -- all = { "\*secret.txt" }, -- Exclude all Android icon files and .ogg files in the "music" directory: -- iphone = { "Icon-\*dpi.png", "music/\*.ogg" }, -- Exclude iOS "retina" image files and .m4a files in the "music" directory: android = { -- "asset/\*/\*@4x.png", -- "asset/\*/\*@4x.jpg", "Default-568h@2x.png", "Default-667h@2x.png", "Default-736h@3x.png", "Default-Landscape-568h@2x.png", "Default-Landscape-667h@2x.png", "Default-Landscape-736h@3x.png", "Default-Portrait@2x.png", "Default-Landscape@2x.png", -- "AppIcon\*", -- "iTunesArtwork\*", } }, android = { -- minSdkVersion = "11", -- Android 3.0.x, http://developer.android.com/guide/topics/manifest/uses-sdk-element.html -- coronaWindowMovesWhenKeyboardAppears = true, CoronaWindowMovesWhenKeyboardAppears = true, useGoogleServicesJson = true, permissions = { { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" }, }, usesPermissions = { "com.android.vending.BILLING", -- in-app purchase -- "android.permission.READ\_PHONE\_STATE", -- "android.permission.VIBRATE", "android.permission.INTERNET", -- "android.permission.GET\_ACCOUNTS", -- For GCM push-notification -- "android.permission.RECEIVE\_BOOT\_COMPLETED", -- For GCM push-notification -- "com.google.android.c2dm.permission.RECEIVE", -- For GCM push-notification -- ".permission.C2D\_MESSAGE", -- For GCM push-notification -- "android.permission.ACCESS\_FINE\_LOCATION", -- "android.permission.ACCESS\_COARSE\_LOCATION", -- "android.permission.STORAGE", -- "android.permission.CAMERA", "android.permission.READ\_EXTERNAL\_STORAGE", -- to access photo gallery -- "android.permission.WRITE\_EXTERNAL\_STORAGE", -- Used in full version, to upload photo }, usesFeatures = { -- If you set permissions "ACCESS\_FINE\_LOCATION" and "ACCESS\_COARSE\_LOCATION" above, -- then you may want to set up your app to not require location services as follows. -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable -- to purchase this app in the app store. }, },

I am pretty sure there are no errors in my build file.

When did you do the build that shows the notification icons?

I am wondering if you did the build before it broke.

Corona Labs wrote the bug fix was in the pipeline back then, so I guess they could reproduce the bug I reported.

I have been using them since 2018 with random daily builds. Works fine.

And now I am using build 2019.3474

Maybe you can attach your icons here for me to try out on my app.

Hey yosu

Very nice of you. I will PM the icons.

Thanks

@yosu I have no idea why this would work for you. As far as I can see it is a bug from coronas side… but I finally found a solution.

After extracting and inspecting the AndroidManifest.xml from the apk I finally figured out what the problem is.

Apparently the build process doesn’t point firebase to the correct notification icon resource path.

Adding this entry to the android build.settings fixed the problem.

android = { applicationChildElements = &nbsp; &nbsp; &nbsp; &nbsp; { [[\<meta-data android:name="com.google.firebase.messaging.default\_notification\_icon" android:resource="@drawable/corona\_statusbar\_icon\_default"/\>]] &nbsp; &nbsp; &nbsp; &nbsp; }, } }

And by the way this one still needs to be fixed: https://forums.coronalabs.com/topic/71552-notificationscancelnotification-not-working/