Skip to main content
Amaresh Pattar (Informatica) 님이 #Apex에 질문했습니다

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일 오전 4: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