Jump to content









Photo

Push data to device (Android)

subscribe gcm

  • Please log in to reply
3 replies to this topic

#1 syntechzob

syntechzob

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationCape Town

Posted 09 November 2015 - 03:45 PM

Hi all.

Firstly to the guys at Carriots thanks for the service.

I have Raspberry pushing data to my device every hour. I also created a Android app. How can I get that data or a notification on the app. In one of the forum posts that I read it was mentioned that work was being done on a subscriber service this was back in April, any word on that?

Can I use Google Cloud Messaging to receive the data or notification when data change?

Thanks

#2 sdeancos

sdeancos

    Master of Puppets

  • Members
  • PipPipPip
  • 103 posts
  • LocationMadrid, Spain.

Posted 10 November 2015 - 11:55 AM

Hi,

 

You can use any HTTP API REST from Carriots' Listeners.

 

Google Cloud Messaging use this request:

 

  https://gcm-http.googleapis.com/gcm/send
  Content-Type:application/json   Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
  {
    "to": "/topics/foo-bar",
    "data": {
      "message": "This is a GCM Topic Message!",
     }
  }

 

You could send a http request in a listener, for example:

 

def basicHttp = new BasicHttp();
basicHttp.url ="https://gcm-http.goo...is.com/gcm/send";
basicHttp.verb ="POST";

basicHttp.headers = ['Content-Type': 'application/json', 'Authorization:key': 'AIzaSyZ-1u...0GBYzPu7Udno5aA']

basicHttp.payload = '{"to": "/topics/foo-bar","data": {"message": "This is a GCM Topic Message!",}}';
basicHttp.send();

 

 

You can learn more about SDK in https://www.carriots...lity_libraries# and more about LISTENER https://www.carriots...create_listener
 

 

 

I hope this help you!

 

BR



#3 syntechzob

syntechzob

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationCape Town

Posted 12 November 2015 - 03:00 PM

Hi

 

Thanks for the reply. Sorry that I'm only now replying.

 

One question, do you know when the Carriots subscriber api will be ready?

 

Steven



#4 syntechzob

syntechzob

    Member

  • Members
  • PipPip
  • 13 posts
  • LocationCape Town

Posted 15 November 2015 - 02:15 PM

Hi

I'm get 401 "Unauthorized error" when I try to send a message to Google Cloud Messaging. I have read the official docs and followed the example of how to construct a message.

 

I tried the code posted by sdeancos in the console and in hurl.it.

 

{
  "to": "<registration_ids>",
  "data": {
    "message": "This is a GCM Topic Message!",
  }
}

 

Does any one know how to get this working?







Also tagged with one or more of these keywords: subscribe, gcm

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users