Code Monkey home page Code Monkey logo

Comments (1)

jchambers avatar jchambers commented on June 22, 2024

@Pro100proff I've looked into this a little more and I think I misunderstood your original report. To be more precisely state what I think is happening here, I understand that:

  • You are using a SimpleApnsPayloadBuilder
  • You are trying to set a custom property, and that value of that property is not a Java primitive, array of primitives, a Collection, or a Map

If I'm understanding you correctly, then this behavior is expected and is, in fact, documented:

/**
* <p>Adds a custom property to the payload. According to Apple's documentation:</p>
*
* <blockquote>Providers can specify custom payload values outside the Apple-reserved {@code aps} namespace. Custom
* values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean.
* You should not include customer information (or any sensitive data) as custom payload data. Instead, use it for
* such purposes as setting context (for the user interface) or internal metrics. For example, a custom payload
* value might be a conversation identifier for use by an instant-message client application or a timestamp
* identifying when the provider sent the notification. Any action associated with an alert message should not be
* destructive—for example, it should not delete data on the device.</blockquote>
*
* <p>The value for the property is serialized to JSON as described in {@link JsonSerializer}.</p>
*
* @param key the key of the custom property in the payload object
* @param value the value of the custom property
*
* @return a reference to this payload builder
*
* @throws IllegalArgumentException if the key equals to "aps"
*/
public ApnsPayloadBuilder addCustomProperty(final String key, final Object value) {
if (APS_KEY.equals(key)) {
throw new IllegalArgumentException("Custom property key must not be aps");
}
this.customProperties.put(key, value);
return this;
}

If you want to change how custom properties are serialized, you'll need to use a different ApnsPayloadBuilder implementation. Pushy offers two as separate modules: GsonApnsPayloadBuilder and JacksonApnsPayloadBuilder.

That said, I think there's room to make the documentation clearer in this case and will open a pull request to do exactly that.

from pushy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.