0
我是新的離子框架。推送通知使用離子和php與明確的例子
我需要在我的移動應用程序中使用離子與谷歌GCM(後端爲PHP)實現推送通知。
我花了很多時間,因此我只有錯誤。所以,我需要一個清晰的例子與PHP。
我是新的離子框架。推送通知使用離子和php與明確的例子
我需要在我的移動應用程序中使用離子與谷歌GCM(後端爲PHP)實現推送通知。
我花了很多時間,因此我只有錯誤。所以,我需要一個清晰的例子與PHP。
對於前端看到Here
對於後端讓你API_ACCESS_KEY的發送捲曲請求GCM。請參見下面的代碼
// API_ACCESS_KEY you can get it from your google account
define('API_ACCESS_KEY', 'AIzaSyA_XXXXXXXvXXXXxxxxxxXXXX');
$msg = array
(
'message' => 'YOUR MESSAGE',
'title' => 'YOUR TITLE',
'vibrate' => 1,
'sound' => 1
// you can also add images, additionalData
);
// registration ids are registered device ids
$registrationIds =['ID1',ID2];
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
我需要前端更多詳細信息...離子前端不正常工作..設備令牌每秒更換 – Balakumaran
http://stackoverflow.com/questions/36762552/ionic-push-notifications-on-android-doesnt-register-token-on-ionic-io/36765094#36765094檢查我的答案android推送通知 –
我不知道關於php後端推送,但前端請參考這個答案 –