locked
How to update app icon badge icon when app is closed RRS feed

  • Question

  • User365758 posted

    I want to update the app icon badge count whenever there are any updates at server end. The server-end updates can be fetched by an api. How to hit that api and how to update the badge count when the application is not open.

    Wednesday, October 17, 2018 2:40 PM

Answers

  • User371688 posted

    You can try to use : FirebasePushNotificationPlugin

    In iOS it is very simple, you just have to send badge count from your server as apart of payload:

       string appleJsonFormat = "{\"aps\":{\"badge\":" + badgeCount + "}, \"content-available\": 1 }";
    
                                apnsBroker.QueueNotification(new ApnsNotification
                                {
                                    DeviceToken = deviceToken,
                                    Payload = JObject.Parse(appleJsonFormat)
                                });
    

    Please refer following link also:

    http://stackoverflow.com/questions/35408704/production-certificate-error-in-push-notification-pushsharp

    For android, you can try to use FirebaseMessagingService of FirebasePushNotificationPlugin and ShortcutBadger

    for more details : https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/129 https://github.com/leolin310148/ShortcutBadger

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 18, 2018 5:57 AM

All replies

  • User371688 posted

    You can try to use : FirebasePushNotificationPlugin

    In iOS it is very simple, you just have to send badge count from your server as apart of payload:

       string appleJsonFormat = "{\"aps\":{\"badge\":" + badgeCount + "}, \"content-available\": 1 }";
    
                                apnsBroker.QueueNotification(new ApnsNotification
                                {
                                    DeviceToken = deviceToken,
                                    Payload = JObject.Parse(appleJsonFormat)
                                });
    

    Please refer following link also:

    http://stackoverflow.com/questions/35408704/production-certificate-error-in-push-notification-pushsharp

    For android, you can try to use FirebaseMessagingService of FirebasePushNotificationPlugin and ShortcutBadger

    for more details : https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/129 https://github.com/leolin310148/ShortcutBadger

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 18, 2018 5:57 AM
  • User365758 posted

    Thanks @jezh for the sharing the link, it helped me a lot . I have done FCM setup in my app and it's working fine. Do you know how to increment the badge count if the user doesn't open the app and there are unread notifications. Do i need to handle it in my app itself or firebase have any alternate for this?

    Thursday, October 25, 2018 9:45 AM