@alutsu wrote:
Hi, I'm trying to register the device tokens when the user has first logged in on my application. The token are registred only when the user has logged a second time.
This is the code
var user = Ionic.User.current(); if (!user.id) { user.id = Ionic.User.anonymousId(); } user.set('name', response.usuarios[0].nome); user.set('grupoabo', response.usuarios[0].grupoabo); user.set('fatorrh', response.usuarios[0].fatorrh); user.set('sexo', response.usuarios[0].sexo); user.save(); push.addTokenToUser(user); user.save(); var userToken = Ionic.User.current(); var callback = function(data) { push.addTokenToUser(userToken); userToken.save(); //alert(data.token); var urlToken = "http://10.19.17.20:8080/HemotoWebService/usuario/insereToken"; var dataFormToken = "id="+UserInfo.getUserId()+"&token="+data.token; //alert(dataFormToken); $http.post(urlToken, dataFormToken) .success(function(response, status, header, config){ //alert(status); }).error(function(error){ alert(error); }); }; push.register(callback);
Posts: 1
Participants: 1