anelezeravla
Posts: 0
Joined: Tue Oct 01, 2013 12:00 pm

Problem with SubscribeChannel and UnsubscribeChannel services

Hello,

I'm following the "sending push notifications to a device" and "sending push notifications from 3rd party apps" tutorials and I have succeded in completing both. Services work ok, test works fine and I can suscribe and unsubscribe from test services. I manage the subscription states with a GetChannels services.

My problem is the following:

I want a toggle control, e.g., when value changes, call to subscribe or unsubscribe services:

if (Appery('mobiletoggle_31').val()=="on"){
localStorage.setItem("recibirAvisos", "on");
rsSubscribeUser.execute();
}else{
localStorage.setItem("recibirAvisos", "off");
rsUnsubscribeUser.execute();
}

rsSubscribeUser and rsUnsubscribeUser are datasources that call to SubscribeChannels and UnsubscribeChannel respectively.

When debugging the application in browser I receive a 400 Bad Request error (see attached image) with this response:

{"code":"PNSI007","description":"Serializationerror"}
and the device not is subscribe to channel:

[
{
"id":2080,
"name":"channel1",
"subscribed":false
}
]

Any ideas?

Thanks in advance.

Image

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

Problem with SubscribeChannel and UnsubscribeChannel services

Hi,

Please share the application with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us how to reproduce the error. We'll take a look.

anelezeravla
Posts: 0
Joined: Tue Oct 01, 2013 12:00 pm

Problem with SubscribeChannel and UnsubscribeChannel services

Thanks Katya, I have shared the app. In order to reproduce the error, follow these steps:

The startScreen has a toggle control (mobiletoggle_31). When this control changes its value, a call is made to the SubscribeChannels and UnsubscribeChannel respectively. This datasources use RESTServices SubscribeChannels and UnsubscribeChannel using default params. This params are my channel and my deviceId.

When debugging the application in browser I receive a 400 Bad Request error with this response:

{"code":"PNSI007","description":"Serializationerror"}

Thank you.

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

Problem with SubscribeChannel and UnsubscribeChannel services

Hello! Could you tell us your app name?

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

Problem with SubscribeChannel and UnsubscribeChannel services

channels should be an array, not a string. That's why in services rsSubscribeUser and rsUnsubscribeUser in request parameters for parameter channels add the following JS code:
prereturn [2093];/pre

Return to “Issues”