Menu

#344 Add support for custom APS properties

open
nobody
None
2018-08-20
2017-07-25
Anonymous
No

Originally created by: raderio

Sometimes Apple can add some new properties to APS object. In order to be able to use that new properties as soon as possible it will be good to add support for custom APS properties.

For example now we can add properties to payload

APNS.newPayload()
    .customField("name", "John")
    ...

How will be to add properties to APS

APNS.newPayload()
    .customAPSField("mutable_content", 1)
    ...

Discussion

  • Anonymous

    Anonymous - 2018-02-01

    Originally posted by: ovictorpinto

    I make a hook to "intercept" the payload generated:

    String payload = builderPayload.build();
    try {
        ObjectMapper mapper = new ObjectMapper();
        JavaType type = mapper.getTypeFactory().constructParametricType(Map.class, String.class, Object.class);
        Map<String, Object> root = mapper.readValue(payload, type);
        Map<String, Object> apns = (Map<String, Object>) root.get("aps");
        apns.put("apns-collapse-id", mensagemTO.getIdFuncionalidade());
        payload = mapper.writeValueAsString(root);
    }catch (Exception e){
        logger.error("Montando mensagem", e);
    }
    
     
  • Anonymous

    Anonymous - 2018-08-20

    Originally posted by: ovictorpinto

    @keilon collapse-id don't work this way. But the hook to insert a property works =]

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.