Skip to content

Instantly share code, notes, and snippets.

@cionman
Last active November 29, 2017 12:06
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/5fd0c9d90e715694137ef41b1cbdd34c to your computer and use it in GitHub Desktop.
Save cionman/5fd0c9d90e715694137ef41b1cbdd34c to your computer and use it in GitHub Desktop.
메세징 알림 권한 획득
<script>
/**
* 초기 필드 변수 할당
*/
FirebaseChat.prototype.init = function(){
//...생략
this.setCloudMessaging();
}
/**
* Cloud Messaging 알림 권한
*/
FirebaseChat.prototype.setCloudMessaging = function () {
//메세징
var messaging = firebase.messaging();
messaging.requestPermission()
.then(function(){
console.log('메세징 권한 획득');
return messaging.getToken();
})
.then(function(token){
console.log('fcm token : ', token);
})
.catch(function(e){
console.log('메세징 권한 획득 중 에러', e);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment