Notificaciones Push iOS 7 no funciona cuando el usuario toca el ícono
Tengo los siguientes métodos para manejar notificaciones push. Funcionan perfectamente cuando la aplicación se está ejecutando y recibo notificaciones cuando la aplicación está en segundo plano. Cuando un usuario toca el ícono, sin embargo, abre la aplicación, pero mi vista de UICollection no se vuelve a cargar de la forma en que lo hace cuando un usuario recibe la notificación cuando la aplicación se está ejecutando.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
// do stuff when app is active
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Ok";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
NSString *type = [userInfo objectForKey:@"type"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Linkedstar"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
if([type isEqualToString:@"message"]) {
alertView.tag = alertMessage;
}
else if([type isEqualToString:@"post"]) {
alertView.tag = post;
}
else if([type isEqualToString:@"contact"]) {
alertView.tag = contact;
}
[alertView show];
[self presentViewForPush:userInfo updateUI:YES];
}
else
{
// do stuff when app is in background
NSLog(@"Received notification: %@", userInfo);
[self handlePush:userInfo updateUI:YES];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSDictionary *pushDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(pushDict)
{
[self handlePush:pushDict updateUI:YES];
}
}
Necesito ayuda para descubrir cómo manejar los datos de launchOptions cuando el usuario toca el ícono. He probado un par de opciones diferentes después de investigar un poco en línea y no funciona. Cualquier ayuda es muy apreciada. Gracias.