Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google GCM 1推送,创建2个通知,而不是1个_Android_Cordova_Push Notification_Google Cloud Messaging_Phonegap Plugins - Fatal编程技术网

Android Google GCM 1推送,创建2个通知,而不是1个

Android Google GCM 1推送,创建2个通知,而不是1个,android,cordova,push-notification,google-cloud-messaging,phonegap-plugins,Android,Cordova,Push Notification,Google Cloud Messaging,Phonegap Plugins,当我运行脚本以通过一条简单消息推送通知时,我在设备中得到的是: (由于我的声誉,我无法发布图像,但它显示的是:2个通知,一个是我的应用程序名称,另一个是消息) 我的应用程序是用phonegap构建的。 安卓版本5 Phonegap版本3.7.0 我使用php脚本通过服务器将通知推送到android设备: $msg = array ( 'message' => 'test test test' ); $fields = array ( 'registration_id

当我运行脚本以通过一条简单消息推送通知时,我在设备中得到的是: (由于我的声誉,我无法发布图像,但它显示的是:2个通知,一个是我的应用程序名称,另一个是消息) 我的应用程序是用phonegap构建的。 安卓版本5 Phonegap版本3.7.0 我使用php脚本通过服务器将通知推送到android设备:

$msg = array
(
    'message'   => 'test test test'

);

$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 );

echo $result;

可能有很多原因导致您在一封邮件中收到两个通知。但我的看法是,请检查以下内容:

  • 以“标题”和“正文”的形式将整个邮件打包发送
  • 检查此PHP脚本以确保您有类似的内容

  • 确保您的清单中只有一个和一个广播接收器来接收广播

include_once './GCM.php';

$gcm = new GCM();

$registatoin_ids = array($regId);
$message = array("price" => $message);

$result = $gcm->send_notification($registatoin_ids, $message);

echo $result;
}
?>