Push test to android cel from Google service and E

9 years 2 months ago #2193 by aldobm
Hello, i shared the code from send messages to android and ios; the service used is www.parse.com/apps , whe press the virtual switch one message is send to my cell Android.

const String ESP8266_IP_ADDRESS = "192.168.1.6";
const String MODULE_ADDRESS = "N3S0";
/*
This code is running one time when program is enabled
*/

public void Setup()

{

System.Net.ServicePointManager.ServerCertificateValidationCallback =new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });

EventHelper.ModuleChangedHandler((o, m, p) =>
{

Console.WriteLine(m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);


if (m.Domain == "Virtual" && m.Address == MODULE_ADDRESS && p.Property == "Sensor.DigitalValue")

Console.WriteLine("aCCION");

System.Net.WebClient client = new System.Net.WebClient();
Console.WriteLine("P1");

client.Headers.Add("X-Parse-Application-Id", "kJ.......a13GsVmtPueXmaI");
client.Headers.Add("X-Parse-REST-API-Key", "NF...............iwXiukH");
client.Headers.Add("HttpRequestHeader.ContentType", "application/json");
Console.WriteLine("P2");

try {
client.UploadString(" api.parse.com/1/push ", "{\"where\":{\"deviceType\":\"android\"},\"data\":{\"alert\": \"Saludos desde easyIoT.\"}}");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

return true;

});



}



/*

This code is running periodicaly when program is enabled.

Cron job detirmine running period.

*/

public void Run()

{

}

Please Log in or Create an account to join the conversation.

Time to create page: 0.169 seconds

Forum latest

  • No posts to display.