Permalink
Browse files

Step 16.5: Create the saveFcmToken Meteor method

  • Loading branch information...
darkbasic committed Jun 8, 2017
1 parent 8927c7d commit e0e7214592920f211fdea383a6aa240b97e1a016
Showing with 8 additions and 0 deletions.
  1. +8 −0 api/server/methods.ts
View
@@ -2,6 +2,7 @@ import { Chats } from './collections/chats';
import { Messages } from './collections/messages';
import { MessageType, Profile } from './models';
import { check, Match } from 'meteor/check';
import { Users } from "./collections/users";
const nonEmptyString = Match.Where((str) => {
check(str, String);
@@ -94,5 +95,12 @@ Meteor.methods({
},
countMessages(): number {
return Messages.collection.find().count();
},
saveFcmToken(token: string): void {
if (!this.userId) throw new Meteor.Error('unauthorized', 'User must be logged-in to call this method');
check(token, nonEmptyString);
Users.collection.update({_id: this.userId}, {$set: {"fcmToken": token}});
}
});

0 comments on commit e0e7214

Please sign in to comment.