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

Added methods for send custom data in iOS push #2

Closed
wants to merge 7 commits into from

Conversation

xPutnikx
Copy link

@xPutnikx xPutnikx commented Sep 2, 2014

Hello!
Thanks for great library!
But in my project I need send some data with push notification, and I don't see this method in your solution.

I hope that my work will be useful.
Best regards, Vladimir.

@evanshortiss
Copy link
Owner

Hi Vladmir,

Thanks for the pull request. I've been looking into your use case and it looks like you want to use the extra parameters supported by iOS Push Notifications such as "sound" and "badge", is this correct?

The library currently supports this via the sendMessage method. The behaviour of sendMessage is designed to be flexible, for simple usage you can provide a String and this will be included in a basic push notification. In your case you should provide an object which will allow you to pass more advanced message options. For example:

ios.sendMessage({endpointArn}, {
  "aps": {
    "alert": "<message>",
    "badge": "2",
    "sound": "alert.wav"
  }
}, callbackFn);

See this line for the code that handle this.

@xPutnikx
Copy link
Author

xPutnikx commented Sep 2, 2014

Hi. Yes, your right.
I have not noticed this case:

if (message !== null && typeof message === 'object') {
    messageContainer[APNS] = JSON.stringify(message);
    return messageContainer;
}

and I think ios.sendMessage always do next logic:

 messageContainer[APNS] = JSON.stringify({
      aps: {
           alert: message
      }
});

Thank you for explain! Great job!

@evanshortiss
Copy link
Owner

Glad I could help!

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

Successfully merging this pull request may close these issues.

None yet

2 participants