gpt4 book ai didi

iOS 10 : Receive Remote Notification in background

转载 作者:行者123 更新时间:2023-11-28 15:25:52 24 4
gpt4 key购买 nike

我正在实现 FCM 推送通知。

当 App 处于前台时,我会收到通知。
但是我没有在后台收到通知。

在服务器端我设置了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'
);

最佳答案

经过 2 个月的努力,我终于通过添加 2 个东西解决了这个问题:
这是所有文档中都缺少的,旨在帮助所有我不希望像我一样挣扎的人

|*|尝试 1):对于 Ios 10 后台通知,在 AppDeligate 中添加以下委托(delegate)方法:

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings)
{
application.registerForRemoteNotifications()
}

Got this solution from : https://codentrick.com/firebase-cloud-messaging-ios/


|*|尝试 2):如果使用 Firebase:在 "info.plist"
中设置一个值属性 ListView :

FirebaseAppDelegateProxyEnabled -> NO

源代码 View :

<key>FirebaseAppDelegateProxyEnabled</key>
<false/>

我只提到了 FirebaseAppDelegateProxyEnable。所以也要注意拼写。

关于iOS 10 : Receive Remote Notification in background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45259797/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com