Retrieve device token from device using ionic framework

后端 未结 3 1676
故里飘歌
故里飘歌 2020-12-05 22:05

I am using ionic to develop an application and I need to get the device token for push notifications, but having trouble. The application isn\'t receiving noti

3条回答
  •  感情败类
    2020-12-05 22:21

    use the below plugin to get the device token value. ionic plugin add phonegap-plugin-push --variable SENDER_ID="GCM_PROJECT_NUMBER"

    please use the below code to get the device token value.

    .run(function($ionicPlatform) {
        $ionicPlatform.ready(function() {
            push = PushNotification.init({
                android: {
                    senderID: "61426985247",
                    sound: "true",
                    vibrate: "true",
                    forceShow: "true"
                },
                browser: {
                    pushServiceURL: 'http://push.api.phonegap.com/v1/push'
                },
                ios: {
                    alert: "true",
                    badge: true,
                    sound: 'false'
                },
                windows: {}
            });
    
    
    
            push.on('registration', function(data) {
    
                alert("device token" + data.registrationId);
    
            });
        });
    })
    

提交回复
热议问题