Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Android Notification Icon is not working
Started by apps30 Apr 23 2019 07:46 PM

10 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

apps30

[GLOBAL: userInfoPane.html]
apps30
  • Enthusiast

  • 76 posts
  • Corona SDK

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.


[TOPIC: post.html]
#2

apps30

[GLOBAL: userInfoPane.html]
apps30
  • Enthusiast

  • 76 posts
  • Corona SDK

anyone?



[TOPIC: post.html]
#3

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 570 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 521 posts
  • Corona SDK

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)

Attached Files



[TOPIC: post.html]
#5

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 570 posts
  • Corona SDK

@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?



[TOPIC: post.html]
#6

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 521 posts
  • Corona SDK

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.

			
        },
	},


[TOPIC: post.html]
#7

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 570 posts
  • Corona SDK

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.



[TOPIC: post.html]
#8

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 521 posts
  • Corona SDK

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.


  • ojnab likes this

[TOPIC: post.html]
#9

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 570 posts
  • Corona SDK

Hey yosu

Very nice of you. I will PM the icons.

Thanks



[TOPIC: post.html]
#10

ojnab

[GLOBAL: userInfoPane.html]
ojnab
  • Contributor

  • 570 posts
  • Corona SDK

@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 =
        {
              [[<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
               android:resource="@drawable/corona_statusbar_icon_default"/>]]
        },
    }
}

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


Edited by ojnab, 01 May 2019 - 09:48 AM.


[TOPIC: post.html]
#11

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 521 posts
  • Corona SDK

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 )



[topic_controls]
[/topic_controls]