I am using Ionic with Ionic Push for push notifications (all works so far).
Part of my mobile app will send a request and somehow programmatically add the token from that device, can anyone explain how I grab the token using my code below?
var io = Ionic.io();
var push = new Ionic.Push({ });
var user = Ionic.User.current();
if (!user.id) {
user.id = Ionic.User.anonymousId();
}
user.set('name', 'Bob');
user.save();
var callback = function() {
push.addTokenToUser(user);
user.save();
};
push.register(callback);
This worked in the end, it might help others
var callback = function(data) {
var token = data.token;
alert('my token: '+ token);
push.addTokenToUser(user);
user.save();
};