【发布时间】:2017-12-28 19:29:33
【问题描述】:
我正在实施 FCM 推送通知。
当应用程序处于前台时,我会收到通知。
但我没有在后台收到通知。
在服务器端我设置了 content-available => true
在 iOS 10 上,我应该实现任何其他方法还是从哪里获得后台通知?
@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void)
{
print("userNotificationCenter : Forground")
completionHandler([.Alert,.Sound,.Badge])
}
@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void)
{
//Code Todo After User presess notification
}
PHP 服务器负载代码:
$payloadFeild = array(
'registration_ids' => $gotoFcmUidVar,
'data' => array('MsgKey'=>json_encode($fcmMsgVar)),
'content_available' => true,
'priority' => 'high'
);
【问题讨论】:
-
您是否已将
Background mode - Notifications添加到您应用的权利中? -
是的,我已启用后台模式 - 远程通知
-
您按照FCM's guide中的步骤操作了吗?
-
是的,我跟着。所以我收到前台通知,他们的指南只谈论前台通知
-
在他们的 repo 中有一个类似的帖子:FCM did not received push notification when background mode for ios10
标签: ios swift ios10 unusernotificationcenter remote-notifications