如何以编程方式触发UILocalNotification?

all*_*ius 1 ios uilocalnotification swift

UILocalNotification有一个.fireDate方法,NSDate作为一个参数然后在那时触发.但是,如果我想在我的代码中发生某些事情而不使用它的话,我该NSDate怎么办?

And*_*rea 5

创建您的UILocalNotification实例并在UIAplication实例上调用该方法-presentLocalNotificationNow:

[[UIApplication sharedApplication]presentLocalNotificationNow:notification]
Run Code Online (Sandbox Code Playgroud)


在SWIFT中:

UIApplication.sharedApplication().presentLocalNotificationNow(notification)
Run Code Online (Sandbox Code Playgroud)