且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iPhone不会触发本地通知

更新时间:2023-02-26 21:05:49

我执行了您的代码,通知没有触发.然后,我取消注释localNotif.alertBody赋值语句,并且确实触发了.如果您未指定alertBody,则本地通知将不会显示为警报.再加上伊丹提出的观点也是有效的.如果您的应用程序位于前台,则不会显示该通知,而您会在应用程序委托中收到回调,在其中应显示一条警报,并显示消息notification.alertBody以确保一致性.

I executed your code and the notification didnt fire. Then I uncommented the localNotif.alertBody assignment statement and it did fire. Local notification will not appear as an alert if you do not specify an alertBody. Plus the point raised by Idan is also valid. If your app is in foreground the notif wont be displayed rather you will get a callback in your app delegate in which you should display an alert with the message notification.alertBody for consistency.

希望这会有所帮助:)

PS,您不需要您做的所有压延组件.记录它们两者,您将看到pickerDate和itemDate都相同.

PS you dont need all the calender components thing youre doing. Log both of them and youll see that both pickerDate and itemDate are same.