Rafael Martínez
Posts: 0
Joined: Tue Apr 23, 2013 5:19 pm

Push notifications and channels

We are confused and we need help about channels for push notifications:

  • How to create a channel. (Channels are created on the server?)

  • How to subscribe the device to a channel

  • How to cancel subscriptions to a channel

    Thanks in advance.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Push notifications and channels

Hi Rafael,

To create channel you'll need first to subscribe the device to the DB the one that is linked to the Push service.
:: http://docs.appery.io/tutorials/sendi...

After the device is subscribed it will appears in the DB as a row with fields:
Image

  • in the field channels you can create appropriate one.

    To subscribe app instance (device) to some channels, send PUT request to according URL:
    precode
    curl -X PUT \
    -H "Content-Type: application/json" \
    -d '{"channels":[<channelId>, &#46;&#46;&#46;]}' \
    https:&#47;&#47;api&#46;appery&#46;io&#47;rest&#47;push&#47;reg&#47;channel&#47;<appType>&#47;<projectGUID>&#47;<deviceID>&#47;add
    /code
    /pre
    where:
    ul
    licode<appType>/code is application platform type (A - Android, I - iOS) (deprecated);/li
    licode<projectGUID>/code is project's GUID (databaseId);/li
    licode<deviceID>/code is unique device identifier;/li
    li"channels" is the list of code<channelId>/code channel identifiers./li
    /ul

    To unsubscribe app instance (device) from some channels, send PUT request to according URL:
    precode
    curl -X PUT \
    -H "Content-Type: application&#47;json" \
    -d '{"channels":[<channelId>, &#46;&#46;&#46;]}' \
    https:&#47;&#47;api&#46;appery&#46;io&#47;rest&#47;push&#47;reg&#47;channel&#47;<appType>&#47;<projectGUID>&#47;<deviceID>&#47;sub
    /code
    /pre
    where:
    ul
    licode<appType>/code is application platform type (A - Android, I - iOS) (deprecated);/li
    licode<projectGUID>/code is project's GUID (databaseId);/li
    licode<deviceID>/code is unique device identifier used in Push Notification registration;/li
    li"channels" is the list of code<channelId>/code channel identifiers./li
    /ul

Carlota
Posts: 0
Joined: Mon Aug 04, 2014 8:10 am

Push notifications and channels

Hi Appery.io support team!

First of all, it's been really exciting to work with Appery.io environment, however I did'nt manage to subscribe to a channel...
I followed the videotutorial; and I managed to test the service succesfully from Test tab app builder tool; but when installing the apk and executing it on the device I get a 400 error.
It is really weird, since I am using the same X-Appery-Ap-Id (actually, it is configured as a default value on Request tab) ...
I enclose some screenshots, just in case you can help me
Thank you in advance!
Carlota F.

Test Tab success screenshot:
Image

Weinre screenshot with 400 error:
Image

Request tab settings:
Image

Carlota
Posts: 0
Joined: Mon Aug 04, 2014 8:10 am

Push notifications and channels

I already found the bug!

On Javascript that converts channel format, the videotutorial (https://www.youtube.com/watch?v=aHFVO...) shows this piece of code:
return (parseInt(value));

However, according to the documentation channels shall be sent as an array. This piece of code works:
var array = [];
array.push((parseInt(value)));
return array;

The error received was also confusing, since the documentation states a 400 error means "App ID not specified".
BR
Carlota F.

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

Push notifications and channels

Hello!

Thank you for this information.
Do you have any problem at the moment?

Carlota
Posts: 0
Joined: Mon Aug 04, 2014 8:10 am

Push notifications and channels

Arina
Sorry for the delay...
No, I have not currently any problem.
Thankx for providing support to this lovely tool!
Carlota F.

Return to “Issues”