Ionic Push one-time push notifications stopped working even though code didn't change [solved]

Yesterday, after following the directions on http://docs.ionic.io/docs/push-from-scratch, I successfully sent many one-time push notifications from the Ionic.io dashboard.

I then wanted to test target push notifications, which requires using the Ionic User service.

I added this code per the docs:

// kick off the platform web client
Ionic.io();

// this will give you a fresh user or the previously saved 'current user'
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.id = 'your-custom-user-id';
}

//persist the user
user.save();

At that point, I re-ran ionic build ios and then, with my phone plugged in via usb to my computer, re-built the app from Xcode, which relaunched the app. I then tried to use target push notifications, but they weren’t going through. So, just to test push notifications in general, I tried sending a one-time push notification again. This time, the push notification did not work. Eventually, I realized that the target notifications were trying to use user_ids and not device tokens. This was the state of my code at that time: https://github.com/stewartmccoy/taggit

So, I removed the Ionic User code above and tried resetting my code back to the state it was in when I first got one-time pushes to work. Unfortunately, I can no longer get the pushes to trigger.

This is an example response code when I send a one-time push:

{"result":"queued","errors":[],"message_id":"d80c7478cb6c11e5ab6e8a009451912b"}

and this is an example message status if I check on that message id:

{"android":{"success":false,"sent":0,"failure_reason":""},"errors":[],"status":"Queued","ios":{"success":false,"sent":0,"failure_reason":""},"app_id":"d2bb004b"}

I tried getting support from the developers on Ionic Platform services (at https://gitter.im/driftyco/ionic-io-testers), but one of the developers told me: “I’d remove the Ionic.io(); call from after your push code. Other than that, you code looks good. The push server appears stable on our end, however, so I’m wondering if anything’s up with your credentials or the token you’re using.”

I haven’t been able to get any guidance on how to verify my credentials or tokens.

Anyway, I’m completely blocked on this and would love some guidance.

Hello,

I don’t see a onNotification handler in you app.js file. See this link: http://docs.ionic.io/docs/push-usage here you can see what you need use to get notifications on you device.

1 Like

Hey Johnno, thanks for getting back to me. I finally learned that I hadn’t set dev_push to false and that was prevent the pushes from going through. Now that I have the pushes working, I definitely need to review the Push Usage docs to setup configuration. Thank you!