我正在圍繞試圖弄清楚這一點。現在推送通知適用於iOS,現在嘗試與android GCM一樣。我被困在如何公開允許我收集用戶註冊ID的服務。使用java是我的服務器真正的痛苦,所以一個PHP唯一的解決方案將是有用的。 我的通知腳本看起來像這樣至今:使用php獲取GCM的android註冊ID使用php
require_once('config.php');
require_once 'Zend/Mobile/Push/Gcm.php';
require_once 'Zend/Mobile/Push/Message/Gcm.php';
$con = mysql_connect($CONFIG['db']['host'] , $CONFIG['db']['user'], $CONFIG['db']['pass']);
if (!$con) {
echo "DBConnectionError: Could not connect to database";
}
$db = mysql_select_db($CONFIG['db']['database'], $con);
if (!$db) {
echo "DBSelectError: Could not select database";
}
// optain list of devices to send pn to
$qt = "SELECT uid userid, apntoken "
. "FROM members "
. "WHERE apntoken IS NOT NULL "
. "AND uid IN ("
. "SELECT fuid userid "
. "FROM avail "
. "WHERE apnsent IS NOT TRUE "
. "UNION "
. "SELECT uid userid "
. "FROM availbinary "
. "WHERE apnsent IS NOT TRUE "
. ") ";
//send gcm message
$message = new Zend_Mobile_Push_Message_Gcm();
$message->setId(time());
$message->addToken($tokenRec['apntoken']);
$message->setData($alert);
$gcm = new Zend_Mobile_Push_Gcm();
$gcm->setApiKey('AIzaSyCxxxxxxxxxxxxxxxnFn5mGkM');
try {
$response = $gcm->send($message);
} catch (Zend_Mobile_Push_Exception $e) {
// all other exceptions only require action to be sent or implementation of exponential backoff.
die($e->getMessage());
}
任何想法,將不勝感激。
這就是我正在尋找的,非常感謝! – Zeb99 2012-07-17 16:27:20