I know i have to manage the badge count for total number of unread messages at my end, but how come server will know what badge count needs to be send from there end. Please let me know.
To set the badge Count, I am running the loop. So if 'IsFeedbackSubmitted' will be false for any object then the badge count will increase by one.
var badgeCount : Int = 0
let index : Int = (self.totalArrayValues.count)!
for counter in 0...index-1{
if (self.arrayValue?[counter].IsFeedbackSubmitted)! == false
{
badgeCount = badgeCount+1
}
self.defaults.set(badgeCount as Int, forKey: "badgeCount")
self.defaults.synchronize()
}
And to set the badge count on app icon i'm adding below code.
if let badgeNumber = self.defaults.value(forKey: "badgeCount") as?Int
{
UIApplication.shared.applicationIconBadgeNumber = badgeNumber
}
else
{
UIApplication.shared.applicationIconBadgeNumber = 0
}
Now this is what i am setting locally at my end, So now my question is how come i maintain the badge count when i'll be getting the badge count back from push notification. So that there will be exactly same number of badge count then there are unread mails. Please let me know if anything required, i am posting the question first time.