Ionic Beta Push integration


#1

Hi I am trying to integrate ionic beta push. but I am unable to send dev token to ionic push server.
could you please help me.

I am unable to see tokens inside push tab.


#2

Sorry you’re having trouble!

Please get it touch with ericb on gitter.
He’ll be able to help you out.

https://gitter.im/driftyco/ionic-io-testers

Also make sure you’re referencing the docs


#3

This is my code for sending the token to the user:

        var push = new Ionic.Push({
            "debug": false
        });

        var callback = function (token) {
            push.saveToken(token); // Push the token to the logged user
        }

       var details = {
              email : 'your-email',
              password : 'your-password'
       }

        Ionic.Auth.login('basic', {"remember": true}, details).then(function (data) {
                push.register(callback);
                $state.go('app.home', {}, {reload: true, inherit: false}); // Let's go home
            }, function (data) {
                console.log(data);
            });

#4

yes i am able to send tokens but i am unable to see the details.name, details.username, custom data.

in ionic push dashboard user details page. I am sending custom data like: details.customdata = {id:123,name:‘user’};


#5

In order to set the user information do this (I know you probably already did that but I had to re-do it when they changed the push version last week) :

  • make sure you have the latest bower version with : npm install -g bower
  • run the command : ionic add ionic-platform-web-client
  • register your app : ionic io init
  • make sure dev is set to false : ionic config set dev_push false

As for the code :

var details = { 
 'name' : 'your-name',
 'email': 'your-email',
 'password': 'your-password'
};

var signupSuccess = function(data){
 user = data.uuid;
}

var user = Ionic.User.current(); // We check if the user exists
 if (!user.id) {
  Ionic.Auth.signup(details).then(signupSuccess, function (data) {
   console.log('error');
   console.log(data);
  });
 }

And if you want to set custom data, you can throw this wherever you want :

var user = Ionic.User.current();
user.set('customdata1', 'value1');
user.set('customdata2', 'value2');
user.set('customdata3', 'value3');
user.save();