0

Server is sending the badge count in push notification, but if app is in background I want to call a service and display the badge count according to the response of that service.

It is possible ignore the badge count came in push from and server and show our desired badge count.

Wos
  • 390
  • 1
  • 16
Aashish Nagar
  • 1,207
  • 1
  • 14
  • 30

2 Answers2

0

To receive a push notification when your app is in the background you need to update the Capabilities of your Target in Xcode and add Background Modes...Remote Notifications. You must then add the key content-available to the payload and set to 1. This will trigger application:didReceiveRemoteNotification:fetchCompletionHandler: See Documentation Here.

Jitendra Modi
  • 2,344
  • 12
  • 34
  • I already did that. I want to know is there any way to ignore the badge count coming in push. I want to show my custom count , instead of count coming in push notification. – Aashish Nagar Oct 21 '16 at 10:00
0

You can update badge count when app goes to background like below. application.applicationIconBadgeNumber = 5; //You can update custom count

If you want to clear the PN or update the count,

You can use Silent push notification concept.

Dharani
  • 44
  • 8
  • When app is in background and it receive push notification with a badge count of 10 but when I call a service and response of that service is 5 badge count. User first see 10 and then 5 badge count. That is the issue. How to fix that ? – Aashish Nagar Oct 21 '16 at 10:27