Hi there,
I want to add a device token to an user in my app. I have the device
token, I have the user, but I cant add the token to the user despite
read a lot of documentation about the issue.
Anyone can help me please?
Here is the code, thanks
`var io = Ionic.io();
username = localStorage.getItem('username');
var signupSuccess = function(user) {
// user was authenticated, you can get the authenticated user
console.log(user);
};
var signupFailure = function(errors) {
for (var err in errors) {
// check the error and provide an appropriate message
// for your application
console.log(err);
user = Ionic.User.current();
console.log(user);
}
};
var details = {
'email': 'email@gmail.com',
'password': 'pass2',
'username':'username'
}
Ionic.Auth.signup(details).then(signupSuccess, signupFailure);
var push = new Ionic.Push();
var user = Ionic.User.current();
console.log('USER',user);
var callback = function(pushToken) {
console.log('Registered tokens:', pushToken.token);
alert('TOKEN: '+pushToken.token);
user.addPushToken(pushToken);
user.save(); // you NEED to call a save after you add the token
}
push.register(callback);`