Swift IOS 7 带有选项的通知警报

Swift IOS 7 notification alert with Options

如何使用关闭、提醒、稍后提醒等三个按钮添加本地通知提醒。

close 将关闭警报 提醒会打开应用程序,稍后提醒也会打开应用程序,我必须导航到应用程序中的不同选项卡。

我知道我们可以在 IOS 8 中使用类别实现此功能,有什么方法可以在 IOS 7 中实现相同的功能吗?

提前致谢。

只需安排一个 UILocalNotification 并在它被触发时弹出一个 AlertView。这是 AlertView 的代码。这是根据您的顶线要求

func openAlertView(消息:字符串!) { 让 topController = UIApplication.sharedApplication().keyWindow!.rootViewController

    let alertController = UIAlertController(title: "Alert Title", message: message, preferredStyle: .Alert)

    let CloseAction = UIAlertAction(title: "Close", style: .Cancel) { (action) in
        // Close Alert
    }
    alertController.addAction(cancelAction)

    let RemindAction = UIAlertAction(title: "Remind", style: .Default) { (action) in

        //Schedule another notification at the preferred time
    }
    alertController.addAction(OKAction)

    topController!.presentViewController(alertController, animated: true) {
    }
let RemindLaterAction = UIAlertAction(title: "RemindLater", style: .Default) { (action) in

        //Schedule another notification at the preferred time
    }
    alertController.addAction(OKAction)

    topController!.presentViewController(alertController, animated: true) {
}