0

I know how to increase badge count. how to send a push notification with badge count.

My question is that how Facebook increase app badge count without push notification if somebody like your post.

If I run service continuously in the background it will drain the battery.

Please suggest the correct way to achieve this.

Bug
  • 2,576
  • 2
  • 21
  • 36
  • 1
    You can use silent notification – Bhupat Bheda Oct 09 '17 at 07:21
  • 1
    Try with silent push. – Fabio Berger Oct 09 '17 at 07:22
  • Thanks, i found more about silent push notification here https://stackoverflow.com/a/36695473/2439156 I inform you once it will work, thanks for your suggestions – Bug Oct 09 '17 at 07:55
  • 1
    @KapilMaheshwari btw, ios11 (incl. 11.0.1 & 11.0.2) has a major issue related silent push. currently it's not working anymore in a terminated or suspended state. It seems that apple fixed the issue with his ios11.1 beta .... for more information: https://stackoverflow.com/questions/46330053/ios11-swift-silent-push-background-fetch-didreceiveremotenotification-is-not/46392357#46392357 and https://stackoverflow.com/questions/44796613/silent-pushes-not-delivered-to-the-app-on-ios-11 – AlexWoe89 Oct 09 '17 at 08:26
  • 1
    Oh I think this issue is just present, if you want to wake up the app to do some stuff in the background. If you just need to update the badge it should hopefully work – AlexWoe89 Oct 09 '17 at 08:32
  • guys thank you so much for the perfect solution that worked for me :) – Bug Oct 09 '17 at 10:58

1 Answers1

-1

I will change the answer that I gave previously since it's wrong.

Then correct answers should be

here is the steps,

1) enable the remote notification on background modes 2) create background notification

{
   "aps" : {
      "content-available" : 1
   },
   "acme1" : "bar",
   "acme2" : 42
}

"content-available" is the one you need to consider and you can add custom keys as above example. an aps dictionary that includes only the content-available key.

3) receive push notifications

Your app has 30 seconds to perform any tasks and call the provided completion handler.

application(_:didReceiveRemoteNotification:fetchCompletionHandler:) 

thats the method.

Here is the more details about it. https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app