據我所知,我們可以處理通過方法推送通知是一樣的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中?