I am new to adding Swift code for push notifications. I did the following and still have no badge count displaying when I send a push notification. I set the applicationIconBadgeNumber in the fetchCompletionHandler function.
Has anyone else had this issue and resolved it? Or is there something else that needs done for badge counts to work using the OneSignal push service?
Thanks so much!
The badge count is handled for you by OneSignal, no need to add your own code to set it. Just set or increase the badge count by the value you want on our dashboard or REST API.
Badge icons are only set when a push notification is received while the app is not in focus or closed.
Let us know if this isn't what you're seeing.
Thanks.
Thank you so much for the reply. This was my ignorance. I was thinking it was all set in the code.
Is there a way to increment badge number when using OneSignal.postNotification ?
Hi,
[OneSignal postNotification:@{@"contents":@{@"en":text}, @"include_player_ids":oneSignalIds,@"content_available":@true,@"ios_badgeType":@"Increase",@"ios_badgeCount":@1}];
I have set ios_badgeType and ios_badgeCount both during sending of Notification so do i need to set anything for receiver side?
when i got notification the application badge doesn't auto incremented.
Keep in mind that the badge count is only incremented when the app isn't open. So if the notification was received while the app was open, the badge count won't increase.
You should not need to do anything on the client side (iOS)
Hi Thanks for your reply,
my badge count was 54. and i removed my app from background. when i got notification the sender send
[OneSignal postNotification:@{@"contents":@{@"en":text}, @"include_player_ids":oneSignalIds,@"content_available":@true,@"ios_badgeType":@"Increase",@"ios_badgeCount":@1}];
but when notification received it starts with 1. why it is not starting with 54?
My simple question is
let notificationReceivedBlock: OSHandleNotificationReceivedBlock = { notification in
is called when application is not in background? if not then which method is called when our application is not in background and we received notification.
Most helpful comment
Is there a way to increment badge number when using OneSignal.postNotification ?