ESP8266 Developer Zone The Official ESP8266 Forum 2021-07-26T17:50:14+08:00 https://bbs.espressif.com:443/feed.php?f=31&t=1716 2021-07-26T17:50:14+08:00 2021-07-26T17:50:14+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1716&p=100085#p100085 <![CDATA[Re: ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER]]>

Code:

https://gcm-http.googleapis.com/gcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}


First I've tryed to use the ajax method:

Code:

var textNotification={
    "notification": {
        "title": "Portugal vs. Denmark",
        "text": "5 to 1"
    }
};
    $.ajax(
    {
        url : "https://gcm-http.googleapis.com/gcm/send",
        type : "POST",
        headers :
        {
            'Authorization' : 'AIzaSyZ-1u...',
            'Content-type': 'application/json'
        },
        data : textNotification
    }
    ).done(function (data)
    {
        console.log(data);
    }
    );


As aspected, due to the fact I'm trying to send an HTTPS request from my PC, it is blocked. Is there another way to follow?

source : https://wasaelgroup.com

Statistics: Posted by RalphKeil — Mon Jul 26, 2021 5:50 pm


]]>
2017-05-22T16:09:28+08:00 2017-05-22T16:09:28+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1716&p=13327#p13327 <![CDATA[ESP8266 GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER]]> Statistics: Posted by JamesRit — Mon May 22, 2017 4:09 pm


]]>
2016-02-02T20:26:05+08:00 2016-02-02T20:26:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1716&p=5635#p5635 <![CDATA[Re: ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER]]> Correct, that is how it works. However I didn't use the "priority" and "time_to_live' keys.

Statistics: Posted by beegee1962 — Tue Feb 02, 2016 8:26 pm


]]>
2016-02-02T17:17:10+08:00 2016-02-02T17:17:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1716&p=5631#p5631 <![CDATA[Re: ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER]]> yes, if the device can get the gcm api_key, and the android registration id, the device can notify without server.

so the first is to pass the android registration id from app to device,
then make a http request to Gcm server, like this:

POST /gcm/send HTTP/1.1
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: gcm-http.googleapis.com
Accept: */*
Authorization: key=${api_key}
Content-Type: application/json
Content-Length: xx

{"registration_ids":%s,"priority":"%s","time_to_live":%s,"data":%s}

registration_ids is a array with android registration ids.

Statistics: Posted by wuyunzhou — Tue Feb 02, 2016 5:17 pm


]]>
2016-02-01T17:33:48+08:00 2016-02-01T17:33:48+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1716&p=5600#p5600 <![CDATA[ESP8266 - GOOGLE CLOUD MESSAGING WITHOUT EXTERNAL SERVER]]>
But what I found on the internet is using an external webserver, able to run PHP (or Python) scripts and using a MySQL server to store registration IDs.
ImageImage
So far so good, but why do I need to setup an external server with MySQL and PHP just to send messages to the Android devices. The ESP8266 has server capabilities build-in and has enough storage to save registration IDs in the Flash memory.
What I wanted is:
ImageImage

As I could not find any tutorial or example on the Internet how to achieve this, I started to write the code by myself.
And here is the result:
ESP8266 - Google Cloud Messaging without external server
Of course the code is open source and stored in my Github repository

Hope it helps someone.

Statistics: Posted by beegee1962 — Mon Feb 01, 2016 5:33 pm


]]>