Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase Badge Count From Client side not from Payload Receive count

I am working on application that receives notification and set application badge.
The problem is that when the application is in background state or terminated, the badge count isn't increased.
It remains same.

While when app is in foreground method calls and badge count increased.
I already did that thing from server side,

but I want to know that Is there any method that execute when app is in background or terminated for increasing application badge number?

I already told you I have done this thing as

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9
    }
}

from server side but what I want is :I dont want to receive that badge count from server payload but I want to increase badge count from my side.

My logic is like that when I receive first notification I saved count in userdeafualts in didReceiveNotification and when I second notification I added count with +1 and when app is in foreground I directly change that badge count as 0 in userdefaults BUT THIS METHOD CANT WORK IN BACKGROUND OR APP TERMINATED

SO I WANT TO KNOW IF THERE IS ANY METHOD THAT EXECUTES IN BACKGROUND OR APP IS TERMINATED SO I CAN INCREASE BADGE COUNT

If anyone knows please help me do it from my side.

like image 768
Jitendra Modi Avatar asked Sep 27 '16 08:09

Jitendra Modi


People also ask

How do I increase notification count on android?

If you want to change badge with number, you can be changed in NOTIFICATION SETTING on the notification panel or Settings > Notifications > App icon badges > Select Show with number.

How do I keep notification badges on Android?

Navigate back to the main Settings screen, tap Notifications, and then tap Advanced settings. Tap the switch next to App icon badges to turn them on.

Why are my app badges not showing numbers iPhone?

The most likely reason that your iPhone badges don't appear to be working relates to notification settings. If you have turned off the badge notifications for an application inadvertently, or the application's default setting is to have badges disabled, you won't receive badge alerts for that application.

What is badge count?

Generally, the badge count for an app reflects the number of unread push notifications that user has received from the app in question.


1 Answers

Use application(_:didReceiveRemoteNotification:fetchCompletionHandler:) of UIApplicationDelegate. System wakes up your app, if you enabled the remote notifications background mode. For more info check the documentation for this method

like image 102
Silmaril Avatar answered Oct 14 '22 06:10

Silmaril