gpt4 book ai didi

当应用程序在前台时,iOS Swift 接收推送通知

转载 作者:可可西里 更新时间:2023-11-01 05:07:41 25 4
gpt4 key购买 nike

这是我在前台应用程序时用来接收推送通知的代码

@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void)
{
completionHandler([UNNotificationPresentationOptions.Alert,UNNotificationPresentationOptions.Sound,UNNotificationPresentationOptions.Badge])
}

但我的问题是我的通知包含 [NSObject : AnyObject] 值。如何接收点赞后台通知

最佳答案

将此代码添加到 AppDelegate.swift 文件中。

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([UNNotificationPresentationOptions.alert,UNNotificationPresentationOptions.sound,UNNotificationPresentationOptions.badge])
}

关于当应用程序在前台时,iOS Swift 接收推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41340515/

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