質問

私はうまく動作して私のアプリを持っており、それがローカル通知を使用しています。

私は今のアプリを国際化し、デバイス上で言語を変更する前に、言語に設定された通知以外のすべての作業だけで罰金を持っていることにしました。

私は、ユーザーがデバイスの言語を変更したときに通知の文字列も変化するであろうことを考え出したが、私は間違っていたので、私は、ローカライズされた文字列を含む配列からの通知でメッセージを取り込みます。

どのように最高のこの問題に取り組むには?私のNSStringのテキストもNSLocalizationStringべきか?

マイ通知コード:

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = [alertTimes objectAtIndex:i];
localNotif.timeZone = [NSTimeZone defaultTimeZone];

NSString *text = [alertText objectAtIndex:i];

// Notification details
localNotif.alertBody = text;
// Set the action button
localNotif.alertAction = @"View";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
localNotif.userInfo = infoDict;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
役に立ちましたか?

解決

  

私のNSStringのテキストもNSLocalizationStringすべきですか?

はい、私はそれを行うだろう。

[alertTimes objectAtIndex:i]NSLocalizedString(@"alertTimes",[alertTimes objectAtIndex:i])を交換してください。私はあなたのローカライズされた文字列に一致alertTimes配列内の文字列を格納することを想定しています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top