我设置推送通知服务"设备和服务器"对于我的应用程序,应用程序在iPhone中正确收到通知但没有声音不播放任何建议?
手机差距代码
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
try {
initPushNotification();
navigator.notification.vibrate(1000);
} catch (ex) {
alert('error: ' + ex);
}
}
function initPushNotification () {
var pushNotification = window.plugins.pushNotification;
pushNotification.register(
app.successHandler,
app.errorHandler,{
"badge" : "true" ,
"sound" : "ture",
"alert" : "true",
"ecb": "onNotificationAPN"
});
// pushNotification.unregister(app.successHandler, app.errorHandler);
};
服务器端代码:
$deviceToken = '**********************3ac58cb70891e04b28';
// Passphrase for the private key (ck.pem file)
// $pass =******* ;
// Get the parameters from http get or from command line
$message = (!empty($_GET['message']))?$_GET['message'] : 'Message text ' ;
$message .= @date("H:i:s d/M/Y", mktime());
$badge = 1;
$sound = 'default';
// Construct the notification payload
$body = array();
$body['aps'] = array('alert' => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
/* End of Configurable Items */
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'push/pushcert.pem');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstr\n";
return;
} else {
print "Connection OK";
}
$payload = json_encode($body);
// request one
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);
插件列表:
感谢您的支持......