请考虑以下问题:
我正在使用以下插件为Xamarin执行推送通知,我试图在iOS和Androids上运行.
我还使用以下PHP代码从网站向设备发送推送通知.
$fields = array
(
'to' => $ID->notification_token,
"content_available" => true,
'priority'=>10,
'notification' => array('title' => 'You have a new message', 'body' => 'Hooray', 'sound'=>'default', 'vibration'=>'default'),
);
$headers = array
(
'Authorization: key=' . PUSH_NOTIFICATION_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;
现在问题出现在iOS上我发现推送通知是可靠的并且当应用程序在前台时运行得很好,但是一旦我将它背景(或锁定屏幕),它们就会停止通过直到我再次前景,然后在后台发送的所有通知都会立即通过.
我根据插件“入门”指南在我的info.plist中启用了后台进程.
我已经尝试将content_availiable更改为content-availiable,同时将其移动到通知数组中,同时将其值设置为true,’true’,1和’1′
我也试过添加“alert”=> “”对于通知和整体有效负载,但是在前景未锁定状态之外我仍然无法使其工作.
我还注意到在实际通知列表中没有任何东西触发(从屏幕顶部拉下来),我知道正在接收通知的唯一方法是播放某个声音文件并在调试中写入登录.
任何帮助将不胜感激,谢谢你的时间.