Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom APS properties #344

Open
raderio opened this issue Jul 25, 2017 · 4 comments
Open

Add support for custom APS properties #344

raderio opened this issue Jul 25, 2017 · 4 comments

Comments

@raderio
Copy link

raderio commented Jul 25, 2017

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)
    ...
@raderio
Copy link
Author

raderio commented Jul 25, 2017

This also will be useful not to wait to add mutable content properties

And will fix
#321
#328

@ovictorpinto
Copy link

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);
}

@keilon
Copy link

keilon commented Aug 18, 2018

As https://stackoverflow.com/questions/44560851/apns-collapse-id-not-merging-multiple-notifications-ios-10 said, "apns-collapse-id" is NOT supported in legacy binary interface, does it really work? @ovictorpinto

@ovictorpinto
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants