1. fireDateを指定する
fireDateにnilまたは過去の時間を指定すると、即座にローカル通知が送信される。
- (IBAction)sendNotification:(id)sender {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = nil;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
2. presentLocalNotificationNow:メソッドを使う
fireDateの値に関わらず、即座にローカル通知が送信される。
- (IBAction)sendNotification:(id)sender {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [[NSDate date] dateByAddingTimeInterval:60];
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
0 件のコメント:
コメントを投稿