10AM GMT問題を繰り返しとUILocalNotificationスケジューリング
-
25-09-2019 - |
質問
これは絶対的なnoobの質問であれば申し訳ありませんが、私はマニュアルまたは他のスタック質問から、このいずれかを把握することはできません -
私は午前10:00 GMTまでNSDateオブジェクトを設定できますか?私が尋ねる理由はこれです - 私は毎日午前10時GMTで発生するlocalnotificationを設定します。
私は次のことが正しい軌道に乗っていると思います:
NSDateComponents *comps = [[NSDateComponents alloc]init];
[comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
[comps setYear:2011];
[comps setMonth:1];
[comps setWeek:1];
[comps setDay:1];
[comps setHour:10];
[comps setMinute:52];
[comps setSecond:0];
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *date = [gregorian dateFromComponents:comps];
[comps release];
UILocalNotification *notif = [[UILocalNotification alloc]init];
notif.fireDate = date;
notif.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
notif.alertBody = @"New Challenges are available in Halo: Reach.\n\n Give them a look over with Halo Reach Challenges!";
notif.alertAction = @"Show Me";
notif.applicationIconBadgeNumber = 5;
notif.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
残念ながら、これは発生しません。任意の助けいただければ幸いです。)
解決
は限り、あなたのアプリが実行されているとして、通知があなたのアプリケーションに直接送信されます。あなたは(appDelegate中)ハンドラと表示メッセージを自分で設定する必要があります。アプリが実行されていない場合、通知が表示されなければならない。
所属していません StackOverflow