終了すると機能しないアプリケーションに取り組んでいます。いくつかのバックグラウンド タスクがあります。アプリが終了した場合にローカル通知を表示したい。これを行うアプリケーションがあり、これは実行可能であることを意味します。しかし、私は方法を見つけることができません。
appdelegate の applicationWillTerminate: メソッドでローカル通知を設定しようとしましたが、viewcontroller にアプリ終了の通知を追加しましたが、アプリが実際に終了したときにどのメソッドも呼び出されませんでした。
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"terminated");
UIApplication * app = [UIApplication sharedApplication];
NSDate *date = [[NSDate date] dateByAddingTimeInterval:15];
UILocalNotification *alarm = [[UILocalNotification alloc] init] ;
if (alarm) {
alarm.fireDate = [NSDate date];
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.repeatInterval = 0;
alarm.alertBody = @"This app does not work if terminated";
alarm.alertAction = @"Open";
[app scheduleLocalNotification:alarm];
}
[app presentLocalNotificationNow:alarm];
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
どんな助けでも素晴らしいでしょう。
前もって感謝します !!!