Ionic Push not registering device tokens

+1, Same issue with android push notifications

1 Like

I’m having the simmilar problem :confused:
pls any one can help us?

Yup Same,

checked http://docs.ionic.io/docs/push-faq#section-no-valid-device-tokens

but that doesn’t help either.

Have you installed bower?

npm install -g bower

For me it was the problem
after the bower install plz update the ionic core and push pluggin :

ionic add ionic-service-core
ionic add ionic-service-push

I hope that can help you

1 Like

@Remy1 Yes I did try that a while back to no avail. This time I tried using the Push starter app and following the directions outlined here.

I am now able to register device tokens, identify and register users for iOS but now sending pushes doesn’t work although their statuses indicate they have been sent successfully.

For instance I’ve sent a push to a device (my own) and here’s the message status:

I thought I should update everyone on the status of my push issues. I have decided not to use Ionic Push, but the Parse push service. It is based off of a REST API that is way easier than Ionic Push IMO.

2 Likes

I get DEV-numbers-numbers-numbers.
My device tokens are not showing in the users section either.
How did you get the real device token?

@andrewoodleyjr See the $cordovaPush plugin here to get the actual device token
http://ngcordova.com/docs/plugins/pushNotifications/

1 Like

@spivotron thanks for recommending the link.

Hi @spivotron,

I am having the same issues with Ionic Push, so I went down the Parse avenue as well. Or at least tried to.

Did you get any errors when you first tried Parse? My app crashes when running in Xcode and I get this message in my output:

*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Could not load NIB in bundle: ‘NSBundle </private/var/mobile/Containers/Bundle/Application/0E835245-160B-4FAD-9D86-90DFAE9E1B9C/UBA Expo.app> (loaded)’ with name ‘ViewController’’

Does anyone know what this means? I have Googled this for the past few days, but I am not getting a clear answer.

@mmilligan Fortunately I did not have any issues with trying Parse. It looks like your code is trying to execute something but failed because it hasn’t been handled properly. You might not have initialized parse correctly.

I used the Javascript SDK from Parse for web. First include this in your index.html file: <script src="//www.parsecdn.com/js/parse-1.5.0.min.js"></script>
Then include this in your app.js: Parse.initialize("APP_ID", "JAVASCRIPT_ID");

I found my problem! I forgot to set my AppID and Client Key inside of my AppDelegate.m file. Once I did that, my app started without a hiccup.

Thanks for letting me know about Parse 1.5.0. I’m not sure if it would of been a huge issue, but I was running off an older version :stuck_out_tongue:

1 Like

+1, Same issue with IOS push notifications

Also, I’m saw Error message “TypeError: Cannot read property ‘pushNotification’ of undefined” when using code below

$cordovaPush.register({
badge: true,
sound: true,
alert: true
}).then(function (result) {

}, function (err) {
console.log(‘reg device error’, err);
});

Any word on this? It appears to be working in simulator (assigns device token) but not in production?

It’s resolved with me.

Can you refer at link: https://github.com/hollyschinsky/PushNotificationSample
and IonicPush: I can't push notification when outside the app

Have a nice day :smile:

I had also this problem, and i resolved checking the inclusion of ‘lib/ionic-service-push/ionic-push.js’ on index.html , which was missing.

Sometimes 'ionic plugin add ’ doesn’t do the trick.

This is how I got GCM working. It’s fairly simple and straightforward.

The ng-cordova plugin on their website is deprecated. You should use this one: GitHub - phonegap/phonegap-plugin-push: Register and receive push notifications

To get the device to register the device you’ve got to use a listener to wait until the device is ready:

var push = PushNotification.init({
“android”: {
“senderID”: “your-GCM-key”,
“icon”: “letters”,
“forceShow”: “true”},
“ios”: {
“sound”: “true”
},
“windows”: {}
} );
document.addEventListener(“deviceready”, function(){
push.on(‘registration’, function(data) {
Data.saveUserToken(data.registrationId);
});

Some other things you need to look out for are that the plugin WILL NOT work in the browser. You have to install it on a device. It will not register a browser and you WILL get the “TypeError: Cannot read property ‘pushNotification’ of undefined” in the browser, but on a device it works fine. Note: If you’re using the ionic push you should be able to do testing in the browser. Lastly, make sure you include ng-cordova BEFORE cordova.

1 Like

I solved using the Ionic.io instead the Angular integration.
First remember to use ionic-platform-web-client instead of ionic-service-push , which is deprecated (see at https://github.com/driftyco/ionic-service-push-client)

Run:

ionic add ionic-platform-web-client

Then, for production:

ionic config set dev_push false

This is my code:

Ionic.io();
var push = new Ionic.Push();
var user = Ionic.User.current();
    
// if the user doesn't have an id, you'll need to give it one.
if (!user.id) {
  user.id = Ionic.User.anonymousId();
}
 
user.set('name', $rootScope.user_name);
user.set('bio', $rootScope.user_bio);
user.save();
    		
 var callback = function(data) {
   console.log('Registered token:', data.token);
   console.log(data.token);
   push.addTokenToUser(user);
   user.save();
}
push.register(callback);
4 Likes

Could you post any test apps by using phonegap-plugin-push. I’m also using this plugin to implement push notification on my Android app. I have some doubts while implementing it.

  1. We need to register our app to ionic.io or not?
  2. How to push the notification from server?
  3. Without register to ionic.io, can we push notification directly by GCM.

Thanks in advance.

@wilsonhobbs I am also trying to do android push notification but i am getting the value like Dev-num-num-num like this how to get the real device token. I am not able to understand what you are doing in app.js and controller.js please can you give me some explanation.