Skip to content

Instantly share code, notes, and snippets.

@Streemo
Created July 24, 2016 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Streemo/2c6953f4d8a775d826f7185a5a6f2a52 to your computer and use it in GitHub Desktop.
Save Streemo/2c6953f4d8a775d826f7185a5a6f2a52 to your computer and use it in GitHub Desktop.
Unified SMS/Push Notification API (android + ios + text messaging), ~WIP
import { Messages } from "./Notifications.js" //import
//uses AWS SNS under the hood for all payload delivery
//send a push notification
//will determine whether or not to send to android or ios automatically.
Messages.send({
title: "This is a short Title",
text: "This is the body of the message and is expected to be more detailed and most likely longer...",
users: ["userId1", "userId2", ...],
data: {
some: "customizedData"
}
})
//send a text message with the same API
Messages.send({
text: "This is the body of the message and there is no Title for text messages",
numbers: ["+1 123 456 7890", "+1 098 765 4321"] //E.164 format
})
//The implementation isn't fleshed out yet, but I'll try and post something to my github soon!
//I've re-written this package: https://github.com/mmmelon/sns-push
//My additions are minimal, I've made mongo updates a bit more efficient and added support for batch sending.
//Also, I've added the ~polymorphic support for sending texts AND push notifications.
@Streemo
Copy link
Author

Streemo commented Jul 24, 2016

Right now, the payload is designed to be used with react-native-push-notifications. That library parses the custom "data" field on the payload (for Android/GCM, at least, haven't tested iOS) in order to show the notification, as opposed to using the specified GCM "notification" field in the payload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment