-
-
Save cionman/ff6546232eb468aa7c7c9df8db8da8d7 to your computer and use it in GitHub Desktop.
FCM 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
<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