Send message to your iPhone and Android phone from your application for free

 

Overview

There are many applications running inside your company’s local network I think. You may want to receive instant notification in event of failure, or you want to receive some customized message by your mobile device (iPhone, iPad, Android phone etc.). And then message is sent from your application.

How to do that?

It is easy to fulfill the target through EasyHA cloud.

How it works?

  • Your application send message to EasyHA server.
  • EasyHA server forward the message to EasyHA cloud.
  • EasyHA cloud push message to your smart phone.
  • You can check the message through your EasyHA app within 2 days. It will be remove about 2 days later.

Requirements

  • You have EasyHA server installed, and then cloud synchronization is enabled.
  • You or your colleagues have EasyHA app installed on your smart phone.
  • Knowledge on HTTP and one programming language.

Send message to EasyHA server

The EasyHA server exports HTTP interface that is invoked to send notifications. You should please edit source code of your application, send http request to EasyHA.

Source code

In this document I will show you the source code in java.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class Test {
public static void postNote(String server,int port,String passcode,String message){
try {
String encoded=URLEncoder.encode(message, "UTF-8");
sendPost("http://"+server+":"+port+"/postNote.action",
"passcode="+passcode+"&message="+encoded);
} catch (Exception e) {
e.printStackTrace();
}
}
private static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream());
out.print(param);
out.flush();
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
e.printStackTrace();
}
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}

}

An example

Provided there is an EasyHA server is running in your local network. Your application can post message to the EasyHA server through HTTP. For example the IP address of the EasyHA server is “192.168.1.234”, the port is 8004, and the passcode is “1234”. The sample code looks similar to this:

postNote(“192.168.1.234”,8004,”1234”,”This is a message”);

Screenshots

  

About the passcode

The initial value of passcode is “1234”.

I suggest you to change the passcode due to security reason. Please click menu “Administration” -> “Configure Passcode”.

Please fill in new passcode and then click “Save” button. The passcode should consist alphanumeric character.

Contact us

We provide general SLA audit report. In case you have special needs, please contact the vendor. http://www.lv2000.com/easyha/contactus.php