2

I am very new to this concept, and I am trying to create a notification, which can be deleted or modified from server, by looking so I came across "apns-collapse-id". The problem is by setting this using the below code does not change the content of notification, it is just like an extra key added.

I'm trying to understand if i need to make any changes to make it work.

   PushNotificationPayload payload = PushNotificationPayload.complex();
   payload = new PushNotificationPayload(){
       public int getMaximumPayloadSize() 
       {
           return 2048;
        }};
   payload.addBadge(1);
   payload.addSound("default");  //No I18N
   payload.addCustomDictionary("rfid","testRfid");
   payload.addAlert("test notification2");

   JSONObject aps = payload.getPayload().getJSONObject("aps");
   JSONObject apsAlert = null;
   try
   {
       apsAlert = aps.getJSONObject("alert");
   }
   catch(JSONException jse)
   {
         apsAlert = new JSONObject();
         try
         {
            String apsAlertMsg = aps.getString("alert");
            if(apsAlertMsg!=null)
            {
                apsAlert.put("body",apsAlertMsg);
            }
          }
          catch(JSONException jse1)
          {
          }
     }

     aps.put("content-available","1");
     aps.put("apns-collapse-id", "12345");
Michael I
  • 21
  • 1
  • l. Anyone found the answer? if yes plese suggest me also my queestion. Unable to set header field “apns-push-type” in Apple Push Notification in javapns – pankaj Apr 18 '20 at 12:10
  • Does this answer your question? [apns-collapse-id not merging multiple notifications iOS 10](https://stackoverflow.com/questions/44560851/apns-collapse-id-not-merging-multiple-notifications-ios-10) – Zig Jul 08 '20 at 14:14

0 Answers0