Sunday, July 9, 2017

You may think that creating notification badge is difficult things on iOS. but this is very simple step how to configure this. I will explain how to create notification badge for your apps. lets start.


First step is setting up permission,  you need to write this on your Appdelegate file. write this on the  
didFinishLaunchingWithOptions method called.

       
//Swift 3
let types:UIUserNotificationType = UIUserNotificationType.badge;
let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(types: types, categories: nil)
UIApplication.shared.registerUserNotificationSettings(notificationSettings)

       
This used for giving permission for your apps to allow for showing notification badge.

And the only last and left thing is set the notification badge count. write this code for updating the count of badge.

      

//Swift 3
UIApplication.shared.applicationIconBadgeNumber = 5


You can place the code on the where you must change the notification count.

Then launch your apps, first you will got pop up for allowing the apps to give you notification (you only got this pop up once).



Then, back to your home and look at your icon apps.



Congratulation, you've success implemented notification badge for your apps. simple right?

Also for the usual iOS apps,  implementing the notification badge is following with the push notification, so the idea is notification badge count will be changed after got new push notification, but not limited to this. on this article I only explain about how to create and change the notification badge. maybe in the future article I will explain for push notification. Thank you!

Contact me

Name

Email *

Message *