This is a migrated thread and some comments may be shown as answers.

App Badge with Push Notifications

3 Answers 240 Views
Push Notifications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dan
Top achievements
Rank 1
Dan asked on 12 Aug 2014, 08:15 PM
I have got Telerik Back End Services set up to send messages to my app on iOs and Android.  I can successfully send a message to the device.

When the app is not running, how can I set a badge on the App's Icon that a push notification has been delivered.

Can this be done without writing a server application to format the notification Json message?

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 13 Aug 2014, 04:40 PM
Hello Dan,

Thank you for contacting Telerik support.

The badge on the app's icon will be automatically set to the value contained in the badge key of the notification payload for iOS. This happens only if the app is in the background when the notification is received. Unfortunately, the notifications sent from the portal does not contain this key in the payload. You will need to send a notification with the following payload (using a tool like Fiddler or Postman):
{
   "IOS": {
        "aps": {
            "alert": "Push message for iOS",
            "badge": 1,
            "sound": "default"
        }
}

More on the supported structure for the notification payload can be read here.

In Android you can set the msgcnt key in order to add a count for the notification entry in the notification tray. 

Please, let us know if you have questions.

Best regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Dan
Top achievements
Rank 1
answered on 13 Aug 2014, 05:36 PM
I am using Telerik Back End Services to send the messages.  I only see a message field.  Is it possible to send more than just a message in the message field or do I have to not use Telerik BaaS to send the notifications to get the badges?
0
Accepted
Anton Dobrev
Telerik team
answered on 14 Aug 2014, 11:02 AM

Hello Dan,

As to your questions.

In short, the value in the "Message" field will be used only to populate the 'alert' field (e.g. the message text) in the payload for iOS, you cannot enter other values.

In details - the Backend Services portal allows you to send a platform-specific and broadcast messages. The current logic that prepares the notification payload has introduced some discrepancies in the result for iOS between the two operations:

- When sending a Broadcast message the payload for iOS will contain the 'badge' field which will place a badge with a number on top of the app's icon. However, a 'sound' key is not included in the payload and the default sound will not be played.
- When sending a Platform Specific message for iOS the payload contains the 'default' sound, but does not contain the 'bagde' and thus a badge is not shown.

The issue is already logged into our backlog.

In the Backend Services API the supported structure for the notification payload is much larger than the functionality offered in the portal. As a temporary workaround to the issue described above and if you would like to send a more tailored and specific payload for each notification you can take a look into the structure and use an external tool, for instance, a tool like Postman or Fiddler. You just need to send the payload as a JSON object in the body of the POST request to the respective endpoint in the Backend Services API.

Please, let us know if further questions arise.

Regards,

Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Push Notifications
Asked by
Dan
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Dan
Top achievements
Rank 1
Share this question
or