Last active
May 20, 2016 06:37
-
-
Save hyperh/bf3509b870f2c61beefa202ce7abd01f to your computer and use it in GitHub Desktop.
Setting device-specific push notification token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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