Can someone help on how to get device token on ios using ionic only. I've managed to get device token using Xcode but is it possible to get device token using ionic only?
I need to to add the device token when the users log in the app
Can someone help on how to get device token on ios using ionic only. I've managed to get device token using Xcode but is it possible to get device token using ionic only?
I need to to add the device token when the users log in the app
using this plugin
cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXX"
in to ionicPlatform.ready
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);
});
I may be very late in answering your question, your answer is as below
cordova plugin add phonegap-plugin-push --variable SENDER_ID="XXXXXXXXX
Next goto src/app/app.component.ts file and add this code after platform.ready().then(()
var push = Push.init({
android: {
senderID: "XXXXXXXXX"
},
ios: {
alert: "true",
badge: true,
sound: 'false'
},
windows: {}
});
push.on('registration', (data) => {
console.log(data.registrationId);
alert(data.registrationId.toString());
});
push.on('notification', (data) => { console.log(data); alert("Hi, Am a push notification"); });