2011-12-07 8 views
1

特定のEST時間にローカル通知を設定する必要があり、ユーザーはユーザーの既定のタイムゾーンに関係なく通知を受け取る必要があります。私は地方の通知が正午の午後12時に到着するようにしたい場合は、太平洋時間帯のあるものも12:00正午09:00 PSTユーザーの既定のタイムゾーンに関係なく、特定のEST時間にローカル通知を設定する

ここにある場合、通知を受け取る必要があります私が実行しようとしましたが、私は私が間違っているつもりですどこ誰かが私に言うことができるEST

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

localNotif.repeatInterval = kCFCalendarUnitDay; 
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar]; 
NSDate *today = [NSDate date]; 

NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit |  NSMonthCalendarUnit | NSDayCalendarUnit) 
               fromDate:today];  
NSDateComponents *dateComps = [[NSDateComponents alloc] init]; 

[dateComps setDay:dateComponents.day]; 
[dateComps setMonth:dateComponents.month]; 
[dateComps setYear:dateComponents.year]; 

[dateComps setHour:12]; 
[dateComps setMinute:00]; 
[dateComps setSecond:00]; 

NSDate *fireDate = [calendar dateFromComponents:dateComps]; 
localNotif.fireDate = fireDate; 
localNotif.timeZone = [NSTimeZone timeZoneWithName:@"US/Eastern"]; 
localNotif.alertBody = @"Daily Notification"; 
localNotif.alertAction = NSLocalizedString(@"View", nil); 
localNotif.soundName = UILocalNotificationDefaultSoundName; 

NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"Daily Notification" forKey:@"acme"]; 
localNotif.userInfo = infoDict; 

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
[localNotif release]; 

に私のデフォルトタイムゾーンを設定するとき、私は通知のみを取得します。

私はここでの問題を発見した

答えて

1

..タイムゾーンは、通知の日付とないために設定する必要がありますので、私はこのコード行を追加する必要があります:

[dateComps setTimeZone:[NSTimeZone timeZoneWithName:@"US/Eastern"]]; 

とコードにコメントすべきです行:

localNotif.timeZone = [NSTimeZone timeZoneWithName:@"US/Eastern"]; 
関連する問題