メソッドを介してプッシュ通知を処理できることを理解しています。
- (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];
これは、ローカライズされていない生のテキストを示しています。たとえば、「%1@ から %2@ に新しいアラートがあります。
私の質問は、loc-args
アプリがフォアグラウンドで実行されているときに、UIAlertView 内に配置するにはどうすればよいですか?