Android 通过firebase收到通知时,Cordova振动不工作
嗨,我在应用程序中工作,它接收推送通知。每件事都很好,但当通知到来时,我并没有得到震动。请帮助我如何解决此错误 我的php代码Android 通过firebase收到通知时,Cordova振动不工作,android,cordova,push-notification,Android,Cordova,Push Notification,嗨,我在应用程序中工作,它接收推送通知。每件事都很好,但当通知到来时,我并没有得到震动。请帮助我如何解决此错误 我的php代码 <?php // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxxx' ); $registrationIds = array( $_GET['id'] ); // prep the bundle $msg = ar
<?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));
?>
你在哪里触发振动?我在我的php文件中触发振动这对我来说毫无意义,要不要解释一下?你在哪里触发振动?我在我的php文件中触发振动这对我来说毫无意义,要不要解释一下?
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";
}
};