Skip to content

Instantly share code, notes, and snippets.

@cionman
Last active November 29, 2017 12:10
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 cionman/ff6546232eb468aa7c7c9df8db8da8d7 to your computer and use it in GitHub Desktop.
Save cionman/ff6546232eb468aa7c7c9df8db8da8d7 to your computer and use it in GitHub Desktop.
FCM Token 저장
<script>
/**
* 로그인 후 세팅
*/
FirebaseChat.prototype.setLogin = function(user){ //user 파라미터 추
//...생략
this.saveFCMToken();
}
/**
* FCM Token 저장
*/
FirebaseChat.prototype.saveFCMToken = function(){
//로그인 후에 fcm 정보를 검색하여 저장
var cbGetToekn = function(token){
console.log('setLogin fcmId get : ', token);
var userUid = this.auth.currentUser.uid;
var fcmIdRef= this.database.ref('FcmId/' +userUid);
fcmIdRef.set(token);
}
firebase.messaging().getToken()
.then(cbGetToekn.bind(this))
.catch(function(e){
console.log('fcmId 확인 중 에러 : ', e);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment