Show UIAlertView that is same as UIRemoteNotification when app is running in foreground
- by Sidwyn Koh
I understand that we can handle push notifications via the method:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
and we can check if the app was running in the foreground:
if (application.applicationState == UIApplicationStateActive ) { ... }
How do we show the exact same notification with localisation?
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];
This shows the raw unlocalized text, e.g. "You have a new alert from %1@ on %2@."
My question is, how can we place the loc-args inside the UIAlertView as well, when the app is running in the foreground?