Using Android Cloud to Device Messaging is the best approach, as you can easily integrate it with MySQL and PhP, having the necessary tools to send a message over the Internet.
You can group users according to your needs:
CREATE TABLE IF NOT EXISTS `gcm_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `gcm_regid` text, `name` varchar(50) NOT NULL, `email` varchar(255) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Source - AndroidHive
Here you have a typical example with a Java class that sends a message over the Internet with a Google cloud :
public class MessageUtil { private final static String AUTH = "authentication"; private static final String UPDATE_CLIENT_AUTH = "Update-Client-Auth"; public static final String PARAM_REGISTRATION_ID = "registration_id"; public static final String PARAM_DELAY_WHILE_IDLE = "delay_while_idle"; public static final String PARAM_COLLAPSE_KEY = "collapse_key"; private static final String UTF8 = "UTF-8"; public static int sendMessage(String auth_token, String registrationId, String message) throws IOException { StringBuilder postDataBuilder = new StringBuilder(); postDataBuilder.append(PARAM_REGISTRATION_ID).append("=") .append(registrationId); postDataBuilder.append("&").append(PARAM_COLLAPSE_KEY).append("=") .append("0"); postDataBuilder.append("&").append("data.payload").append("=") .append(URLEncoder.encode(message, UTF8)); byte[] postData = postDataBuilder.toString().getBytes(UTF8);
To wrap it, you can integrate your query using MySQL with PhP to achieve what you want. Here you have the server side with an example PhP :
send_message.php <?php if (isset($_GET["regId"]) && isset($_GET["message"])) { $regId = $_GET["regId"]; $message = $_GET["message"]; include_once './GCM.php'; $gcm = new GCM(); $registatoin_ids = array($regId); $message = array("price" => $message); $result = $gcm->send_notification($registatoin_ids, $message); echo $result; } ?>
Here you will find some additional examples that may arise in the hand, including system logic:
Taking from here you can get your application with the features that you have in mind.
Avanz
source share