我需要您的帮助,Google通知发送功能正常,但邮件,标题,消息等空缺...
有什么想法吗?
define( 'API_ACCESS_KEY', 'AIzaSyBBh4ddPa96rQQNxqiq_qQj7sq1JdsNQUQ' );
//$registrationIds = array( $_GET['id'] );
$user_device_key = 'eVuuhJNB3vs:APA91bGyf2iAcDEHMVe8MmYzUmNAVl08tfP4wHQFi0sIMhtlZ9PwljdEfZ8JhtfJ_O0rhXTvdJEiVbeRJaUfWn2qvHG6Gw7OjV2jSCmkUd1HK93dyocyC26_48xb0srxa5imUpqXSxMk';
$payload_info = create_payload_json("I know how to send push notifications!");
// API access key from Google API's Console
define('API_ACCESS_KEY', 'AIzaSyAjcvboyovxihsZBtrs2FmVkFbLs-bNk1k');
// prep the bundle
$msg = array
(
'message' => json_decode($payload_info)->aps->alert,
'title' => 'This is a title. title',
'subtitle' => 'This is a subtitle. subtitle',
'tickerText' => 'Ticker text here...Ticker text here...',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'registration_ids' => array($user_device_key),
'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, false );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
echo $fields;
$result = curl_exec($ch);
curl_close($ch);
return $result > 0;
function create_payload_json($message) {
//Badge icon to show at users ios app icon after receiving notification
$badge = "0";
$sound = 'default';
$payload = array();
$payload['aps'] = array('alert' => $message, 'badge' => intval($badge),'sound' => $sound);
return json_encode($payload);
}