Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Always include 'aps' key #49

Closed
wants to merge 1 commit into from

Conversation

hipsterjazzbo
Copy link
Contributor

In #18, a change was made to exclude the aps key if it is empty. This causes totally empty notifications to fail (for example, when pushing to an Apple Wallet pass to trigger an update). The correct behavior to would be to include the empty aps key encoded as a JSON object, like this:

{
    "aps": {}
}

This PR fixes this by always including the "aps" key and casting $aps to an object, so that in the event it is empty it will be correctly encoded as an empty JSON object, rather that an empty JSON array as mentioned in #18.

Reference:

For each notification, compose a JSON dictionary object (as defined by RFC 4627). This dictionary must contain another dictionary identified by the aps key.

weierophinney added a commit that referenced this pull request May 8, 2018
weierophinney added a commit that referenced this pull request May 8, 2018
As written in #49, tests broke. This patch:

- Fixes a broken test
- Modifies the `Message::getPayload()` routine to cast an empty `$aps`
  value to an empty object (to ensure it gets serialized correctly),
  while leaving other values intaqct.
- Updates the test introduced in #18 to instead check for an empty
  object value for `aps`.
weierophinney added a commit that referenced this pull request May 8, 2018
weierophinney added a commit that referenced this pull request May 8, 2018
@weierophinney
Copy link
Member

Thanks, @hipsterjazzbo; merged to develop for release with 1.3.0

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

Successfully merging this pull request may close these issues.

None yet

2 participants