Amanda
Posts: 0
Joined: Fri Jan 17, 2014 5:33 am

Getting a device's push notification channels

I am not understanding something, I guess.
When the device is ready, I want to send a query to find out what channels the device is subscribed to. I tried using this: http://docs.appery.io/documentation/b... but I'm having trouble.

I am using the URL https://api.appery.io/rest/push/reg/201.... (my deviceId at the end)
I set up the proper request parameters - X-Appery-App-id and deviceId.
When I test it with the test button, it does work.

I set up a mapping. I get the deviceId with the Javascript:
var deviceID = localStorage.getItem('pushNotificationDeviceID');
return encodeURIComponent(deviceID);
I invoke the service on deviceReady. But nothing happens. I am testing on an iPhone.

What I don't understand is why I have to put the deviceID in the URL. Why isn't it enough to send it as a parameter? If I have to put it in the URL, how do I set that dynamically from the device?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Getting a device's push notification channels

Hello!

Add events on success and error service events. Using alerts show what service returns. It might help to figure out what is the error there. [quote:]how do I set that dynamically from the device[/quote]the code you posted is exactly to set it dynamically. Could you post service settings and mapping screenshots?

Amanda
Posts: 0
Joined: Fri Jan 17, 2014 5:33 am

Getting a device's push notification channels

As you can see, the device ID is in the URL here as per the tutorial. That doesn't seem right. If I remove it, the test no longer works even though I also have a deviceId parameter:
Image

Image

I cannot find a place to add events on success and error, though I'd like to be able to do that.
Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Getting a device's push notification channels

You haven't reached that part with error and success events yet. They should be set on Data tab.
You need to change service URL and instead id you have there add {deviceId} so that it looks like this prehttps://api.appery.io/rest/push/reg/{deviceId}/preIn this case deviceId request parameter is added to URL.

Amanda
Posts: 0
Joined: Fri Jan 17, 2014 5:33 am

Getting a device's push notification channels

Thanks! That was just what I was looking for. I didn't know about the curly brackets.

I also found the success and error events on the mapping screen. I had already set up a mapping and had been on that page many times. Not sure why I never noticed the events at the bottom!

One side note for anyone else trying this... several times the Javascript that I added on the Request mapping for deviceId disappeared. I'm not sure when or why. Maybe when I added a parameter to the Response, or when I remapped the Response. All I know is, check that your code is still there when you make a change.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Getting a device's push notification channels

Hi Amanda,

Probably you didn't save your changes. Thank you for the feedback.

Return to “Issues”