Skip to main content

Hi All,

Is there a way to set content-available:1 in IOS push notification inside "aps

". As following methods are adding this to additional info of the push notification.

  1. apple(alert, sound, badgeCount, userData)
  2. apple(alertBody, actionLocKey, locKey, locArgs, launchImage, sound, badgeCount, userData)

I need it as follow:

{

         "aps": { "alert": "Test background push", "content-available": 1 }

}

but these methods are adding in following format

{

      "aps": { "alert": "Test background push" },

      "custom-payload": { "content-available: 1 }

}

Please let me know If you know the solution. It is an urget requirement.

Thanks in advance,

Amaresh
1 个回答
  1. 2017年2月8日 04:41
    Hi Amaresh

    You may need to use PushNotificationPayload.apple method to construct the payload and then append  'content-avaialbe' attribute to aps .

    Map<String, Object> applePayload =  Messaging.PushNotificationPayload.apple(<alert text>,<alert sound>,<badge count>, <free-form data>);

       

    //now append 'content-available' parameter to aps        

    Map<String, Object> aps = (Map<String, Object>)applePayload.get('aps');

    aps.put('content-available', 1);        

    //
0/9000