据我所知,我们可以处理通过方法推送通知是一样的UIRemoteNotification:显示UIAlertView中,当应用程序在前台运行
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
,我们可以检查,如果应用程序是在前台运行:
if (application.applicationState == UIApplicationStateActive) { ... }
我们如何显示与本地化完全相同的通知?
NSString *message = [[[userInfo valueForKey:@"aps"] valueForKey:@"alert"] valueForKey:@"loc-key"];
NSString *trueMessage = NSLocalizedString(message, nil);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert"
message:trueMessage
cancelButtonItem:@"OK"
otherButtonItems:@"Show", nil];
[alertView show];
这显示原始未定位文本,例如, “您在%2 @上有来自%1 @的新提醒。”
我的问题是,当应用程序在前台运行时,我们如何将loc-args
放置在UIAlertView中?