我已经添加了
'content_available' => true,//to trigger when iOS app is in background 'priority' => 'high', 'notification' => $data, $data = array( 'message' => 'Hello World!', 'body' => 'Hello World!');
您的代码。请尝试以下代码;
<?php// Payload data you want to send to iOSdevice(s)// (it will be accessible via intent extras) $data = array( 'message' => 'Hello World!', 'body' => 'Hello World!');// The recipient registration tokens for this notification// http://developer.android.com/google/gcm/ $ids = array( 'kucy6xoUmx********eeRsla' );// Send a GCM pushsendGoogleCloudMessage( $data, $ids );function sendGoogleCloudMessage( $data, $ids ){ // Insert real GCM API key from Google APIs Console // https://pre.google.com/apis/console/ $apiKey = 'AIz******9JA'; // Define URL to GCM endpoint $url = 'https://gcm-http.googleapis.com/gcm/send'; // Set GCM post variables (device IDs and push payload) $post = array( 'registration_ids' => $ids, 'data' => $data, 'content_available' => true, 'priority' => 'high', 'notification' => $data, ); // Set CURL request headers (authentication and type)$headers = array( 'Authorization: key=' . $apiKey, 'Content-Type: application/json' ); // Initialize curl handle$ch = curl_init(); // Set URL to GCM endpoint curl_setopt( $ch, CURLOPT_URL, $url ); // Set request method to POSTcurl_setopt( $ch, CURLOPT_POST, true ); // Set our custom headerscurl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); // Get the response back as string instead of printing itcurl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // Set JSON post data curl_setopt( $ch, CURLOPT_POSTFIELDS, json_enpre( $post ) ); // Actually send the push $result = curl_exec( $ch ); // Error handling if ( curl_errno( $ch ) ) { echo 'GCM error: ' . curl_error( $ch ); } // Close curl handle curl_close( $ch ); // Debug GCM responseecho $result;}?>在IOS方面;遵循GCM网站上的订单
编辑1: 您可以尝试发送ios通知;
我在上面编辑了您的php代码;变化是;
‘通知’=> $ data,
和
$ data = array(’message’=>’Hello World!’,’body’=>’Hello World!’);



