setting "apns-collapse-id" in apns header

746 Views Asked by At

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");
0

There are 0 best solutions below