Reputation: 135
I am trying to implemented ionic push from ionic.io. Sending push to all users are working, but sending push to a specific user is not working. The codes for ionic push are following as below:
function IonicPushInit(){
var push = new Ionic.Push();
var callback = function(token) {
push.saveToken(token);
}
push.register(callback);
}
function IonicIoLogin(){
var user = Ionic.User.current();
if (user.isAuthenticated()) {
IonicPushInit();
} else {
var details = {
'email': '[email protected]',
'password': 'secretpassword'
};
var options = { 'remember': true };
Ionic.Auth.login('basic', options, details).then(function(sucRes){
IonicPushInit();
}, function(err){
Ionic.Auth.signup(details).then(function(s){
IonicPushInit();
}, function(e){
alert(e);
});
});
}
}
IonicIoLogin();
After execute above codes, when I send a push to all users from ionic.io, it works. But if I send a push to a specific user with following condition, it doesn't work.
So I've checked the user "[email protected]" in User Tab, but in ther the push tab is empty. Is this the reason? Why it is empty?
What's wrong with above the codes?
Upvotes: 2
Views: 709
Reputation: 98
Your code seems good, so it has to be something with project configuration.
Did you follow ionic documentation to use "Full setup"? Assign tokens to real users does not work on "Limited setup" => http://docs.ionic.io/docs/push-full-setup
After follow steps of "Full setup" I had your problem. Then I realized that register doesn't work in browser or emulator. You have to try it on real device.
To have more information about your register function, just use:
var push = new Ionic.Push({"debug": true});
Upvotes: 1