Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve device token from device using ionic framework

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 notifications, but I still need to send device token when user login into the application (e.g. I need to get device token without receiving notifications). I tried using the Cordova push notification plugin also.

like image 556
Manoj Rejinthala Avatar asked Apr 19 '16 11:04

Manoj Rejinthala


1 Answers

I've used phonegap-plugin-push plugin and its pretty easy and simple. For regID in the code on deviceReady event I've used.

var push = PushNotification.init({
        "android": {
            "senderID": "SENDER-ID"
        },
        "ios": {"alert": "true", "badge": "true", "sound": "true"}, 
        "windows": {} 
    });

    push.on('registration', function(data) {
        console.log("registration event");
        //here is your registration id
        console.log(data.registrationId);
    });

This is the link of the tutorial too

Hope it helps.

like image 120
M. Junaid Salaat Avatar answered Oct 04 '22 02:10

M. Junaid Salaat