【发布时间】:2015-01-02 23:21:28
【问题描述】:
我有一种“警报应用”,当某个计时器达到零时,它应该会给用户一个声音。 仅出于测试目的,我实现了通知,因为我不知道如何在应用程序处于后台时显示警报控制器。 此外,通知工作得很好,但在模拟中它给了我我选择的警报声音,而在我的 iPhone 中它使用我的通知设置的标准铃声。 总之,我有两个问题: 1. 是否可以在应用程序处于后台时显示警报控制器 2.当通知发生时我有两种不同的声音。我将通知实现如下
在AppDelegate 在didFinishLaunchingWithOptions 方法中
let notificationSettings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert | UIUserNotificationType.Sound | UIUserNotificationType.Badge, categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
在applicationWillResignActive
NSNotificationCenter.defaultCenter().postNotificationName("scheduleNotifications", object: self)
scheduleNotifications 被实现为我的 ViewController 的方法
【问题讨论】:
标签: ios swift notifications uialertcontroller