Skip to content

Instantly share code, notes, and snippets.

@hyperh
Last active May 20, 2016 06:37
Show Gist options
  • Save hyperh/bf3509b870f2c61beefa202ce7abd01f to your computer and use it in GitHub Desktop.
Save hyperh/bf3509b870f2c61beefa202ce7abd01f to your computer and use it in GitHub Desktop.
Setting device-specific push notification token
const SET_PUSH_TOKEN = 'notifications.set.pushToken';
Meteor.methods({
'notifications.set.pushToken'({token, os}) {
check(arguments[0], {
token: String,
os: String,
});
const userId = this.userId;
if (!userId) {
throw new Meteor.Error(SET_PUSH_TOKEN, 'Must be logged in to set push notification token.');
}
Meteor.users.update(userId, {
$addToSet: { pushToDevices: { token, os } },
});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment