Push Notification Change AppIcon

I am working on an application that can get Push-Notifications

. When the notification is received, I need to change the icon number of the icon and increase it. These notifications are stored UITableView

in my application. When the line is clicked it means the notification has been read, so I want to make the icon smaller. I'm new to distributing notifications and icons and I really couldn't find an efficient way to do this.

any solutions?

Thank.

+3


source to share


1 answer


You cannot automatically enlarge the icon from a notification. Your notification payload should contain a property badge

that will be set to the exact value you want for your icon.
To set the value of an icon from your application, you can use:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:someInteger];

      



If you want to enlarge the icon every time you receive a notification, you need to keep an eye on your custom icon on the server side.
For example, if you send 3 notifications to a user, you will have a column badge

in your database for that user with 3 as the value. If the user opens their app and removes one of the notifications, your app will have to set the icon to 2 and send a request to your server to reduce the database value to 2.

TL; DR: There is no such thing as badge:+1

or in the notification payload badge:autoincrement

. You have to keep track of the server side icon meaning.

+9


source







All Articles