0
votes

The Worklight adapter code for sending push notifications seems to require that the badge number be provided. I have the need to send a notification, but, don't want to update the badge number on the app.

When I try to send the notification without the badge (i.e. don't define the badge using: notification.APNS.badge=MYBADGENUMBER), the following error is received:

    Mandatory field 'badge' not found.

Is there anyway to avoid sending a badge number to update?

Using Worklight 6.0.0.20130909-1459.

1

1 Answers

0
votes

Edit: Based on the discussion in the comments I have modified the answer and opened a defect for investigation.

Edit 2: This defect is now fixed and will be available in future fixpacks

The documentation for WL.Server.createDefaultNotification() states that the badge property is optional but in actuality it is required by the framework while it should not be.

The only workaround seems to be to:

  1. Remember the current value of the badge
  2. Use badge:0 when sending the push notification
  3. Use WL.Badge to re-apply the previous badge value from 1

Note that Worklight does not provide any mechanism for updating Badges other than setting or removing (with the exclusion of the TabBar which allows updating as well). So if you send lots of updates you will need to write such a mechanism on your own in order to control the sorting, updating, etc.