-
-
Save cionman/5fd0c9d90e715694137ef41b1cbdd34c to your computer and use it in GitHub Desktop.
메세징 알림 권한 획득
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.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