gpt4 book ai didi

ios - 如何从解析中注册声音和警报的通知? (在 swift 中)

转载 作者:行者123 更新时间:2023-11-29 02:11:00 24 4
gpt4 key购买 nike

我正在使用解析通知,但我希望通知能够发出警报和声音。我现在有这个:

 var pushSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: .Alert, categories: nil)

但是我如何注册 .sound?在 Objective-C 中显然是这样的:

 // Let device know you're going to be sending one of these types of notifications.
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

但是,我对 Swift 很陌生,我真的不知道如何在 Swift 中使用它!

提前致谢!

最佳答案

这应该有效...

let pushSettings = UIUserNotificationSettings(forTypes: .Alert | .Badge | .Sound, categories: nil)

关于ios - 如何从解析中注册声音和警报的通知? (在 swift 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29289382/

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