且构网

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

为本地通知添加振动背景

更新时间:2023-02-26 21:18:19

您可以在将来创建通知,当它被调用时取消所有以前的通知并重新安排,直到您满意为止.

You can create a notification in the future and when it gets called cancel all the previous ones and reschedule until you're satisfied.

  UILocalNotification* localNotification = [[UILocalNotification alloc] init];
                        localNotification.alertBody = body;
                        localNotification.timeZone = [NSTimeZone defaultTimeZone];
                        localNotification.fireDate = [NSDate new]; //<-Set the date here in 10seconds for example
 [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

然后在应用中 didReceiveLocalNotification:(UILocalNotification *)notification:

Then in application didReceiveLocalNotification:(UILocalNotification *)notification:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    application cancelAllLocalNotifications;
}