您好我正在接收推送通知的应用程序中工作。每件事情都运转正常,但是当得到通知时我没有得到振动。请帮忙我如何解决这个错误??
我的PHP代码
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxxx' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
(
'body' => $_GET['body'],
'title' => $_GET['title'],
'vibrate' => true,
'sound' => true,
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/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;
echo json_encode(array("data"=>$msg));
?>
我的代码
FCMPlugin.onNotification(function(data){
if(data.wasTapped){
//alert( JSON.stringify(data.title) );
if(data.title=="New Order"){
// alert("->"+data.body);
localStorage.setItem("orderr", JSON.stringify(data.body));
window.location="new_order.html";
}
}else{
// alert( JSON.stringify(data) );
if(data.title=="New Order"){
// alert("->"+data.body);
localStorage.setItem("orderr", JSON.stringify(data.body));
window.location="new_order.html";
}
}
},
function(msg){
//alert('onNotification callback successfully registered: ' + msg);
},
function(err){
// alert('Error registering onNotification callback: ' + err);
}
);
function onBackKeyDown() {
alert("Can't Go Back");
//navigator.app.backHistory();
// window.location="main.html";
}
};