我的应用程序运行良好,它使用本地通知。
我决定现在将应用程序国际化,并让一切工作正常,除了在更改设备上的语言之前设置为语言的通知。
我从包含本地化字符串的数组中填充通知中的消息,所以我认为当用户更改设备的语言时,通知中的字符串也会改变,但我错了。
如何最好地解决这个问题?我的 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];