Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Badge Number in Background Notification on Android #379

Open
ash737 opened this issue Oct 21, 2022 · 4 comments
Open

Update Badge Number in Background Notification on Android #379

ash737 opened this issue Oct 21, 2022 · 4 comments

Comments

@ash737
Copy link

ash737 commented Oct 21, 2022

I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated
Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload

How to get this work using ShortcutBadger and FCM?

@ash737 ash737 changed the title Update BadgeNumber in Background Notification on Android Update Badge Number in Background Notification on Android Oct 21, 2022
@aravindforums1
Copy link

aravindforums1 commented Nov 17, 2022

I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload

How to get this work using ShortcutBadger and FCM?

Hi did u get badge count in app icon for ios and android ? or ios only ? pls reply i stuck in show badge count in app icon for android cant find it.
Can you share code how to set badge count and update ?

@ash737
Copy link
Author

ash737 commented Nov 17, 2022

Hi,
In iOS, you have to store notification info into database then, calculate badge number, increase one, and set it in payload as badge:

function send_notification ($notiunreadNO, $token, $message, $title)
{
    $notiunreadNO = $notiunreadNO + 1;
    
	$fields = array(
		'to' => $token,
		'notification' => array('title' => $title, 'body' => $message, 'click_action' => 'FCM_PLUGIN_ACTIVITY', 'badge' => $notiunreadNO),
		'data' => array('title' => $title, 'body' => $message),
		'sound' => 'default'
	);
}

For android, I still looking for a solution.

I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload
How to get this work using ShortcutBadger and FCM?

Hi did u get badge count in app icon for ios and android ? or ios only ? pls reply i stuck in show badge count in app icon for android cant find it. Can you share code how to set badge count and update ?

@aravindforums1
Copy link

Hi, In iOS, you have to store notification info into database then, calculate badge number, increase one, and set it in payload as badge:

function send_notification ($notiunreadNO, $token, $message, $title)
{
    $notiunreadNO = $notiunreadNO + 1;
    
	$fields = array(
		'to' => $token,
		'notification' => array('title' => $title, 'body' => $message, 'click_action' => 'FCM_PLUGIN_ACTIVITY', 'badge' => $notiunreadNO),
		'data' => array('title' => $title, 'body' => $message),
		'sound' => 'default'
	);
}

For android, I still looking for a solution.

I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload
How to get this work using ShortcutBadger and FCM?

Hi did u get badge count in app icon for ios and android ? or ios only ? pls reply i stuck in show badge count in app icon for android cant find it. Can you share code how to set badge count and update ?

Ok , Thanks for your reply, i tried with "cordova-plugin-firebase-messaging 7.0.4 "FirebaseMessagingPlugin" , but still cant in Android, If found solution, please share it.

@aravindforums1
Copy link

Hi, In iOS, you have to store notification info into database then, calculate badge number, increase one, and set it in payload as badge:

function send_notification ($notiunreadNO, $token, $message, $title)
{
    $notiunreadNO = $notiunreadNO + 1;
    
	$fields = array(
		'to' => $token,
		'notification' => array('title' => $title, 'body' => $message, 'click_action' => 'FCM_PLUGIN_ACTIVITY', 'badge' => $notiunreadNO),
		'data' => array('title' => $title, 'body' => $message),
		'sound' => 'default'
	);
}

For android, I still looking for a solution.

I'm using ShortcutBadger latest version with cordova-plugin-fcm-with-dependecy-updated Notification badge update ok in ios by set badge number in payload but, in android cannot set badge in payload
How to get this work using ShortcutBadger and FCM?

Hi did u get badge count in app icon for ios and android ? or ios only ? pls reply i stuck in show badge count in app icon for android cant find it. Can you share code how to set badge count and update ?

Could you share code which set badge in device ? i mean how to set badge count in mobile device , above is payload to send notification, but i need in mobile device how to set count ?
Point 1 and 2 in which file need to add and point 3 ondeviceready function need to add ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants