最近我已经在我的应用程序最近的版本集成了FCM,但我的以前版本的应用程序使用GCM。关于我们是否需要分离为GCM和FCM编写背景cron的任何想法?Pushnotification服务器端执行
我的以前的版本我的应用程序4.0,并使用GCM和当前版本我的应用程序4.1并集成了FCM。我想为版本和用户发送推送通知。那么我们是否需要为GCM和FCM编写服务器端程序?关于这种整合的任何想法。
FCM服务器端API:https://fcm.googleapis.com/fcm/send GCM服务器端API:https://android.googleapis.com/gcm/send
任何其他possiblies可我们发送通过FCM服务器端程序的通知?或者单独编写GCM和FCM的程序?在PHP
<?php
function sendFCM($mess,$id) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array (
'to' => $id,
'notification' => array (
"body" => $mess,
"title" => "Title",
"icon" => "myicon"
)
);
$fields = json_encode ($fields);
$headers = array (
'Authorization: key=' . "AIzaSyA9vpL9OuX6moOYw-4n3YTSXpoSGQVGnyM",
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec ($ch);
curl_close ($ch);
}
?>