changement de vue dans didReceiveRemoteNotification
Bonjour tout le monde,
Je débute avec le développement d'Ios.
Voila j'aimerai changer de vue lorsque je reçoit une notification (PUSH). J'ai bien la fonction didReceiveRemoteNotification qui permet de réaliser des actions lorsque l'application reçoit un push.
Est ce que vous pouvez me donner la démarche a suivre?
Voila mon code mais ca ne marche pas.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
#if !TARGET_IPHONE_SIMULATOR
NSLog(@"remote notification: %@",[userInfo description]);
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);
NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
NSString *badge = [apsInfo objectForKey:@"badge"];
NSLog(@"Received Push Badge: %@", badge);
application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
//Transition Custom
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
transition.duration = 0.3f ;
transition.fillMode = kCAFillModeForwards;
transition.removedOnCompletion = YES;
[[UIApplication sharedApplication].keyWindow.layer addAnimation:transition forKey:@"transition"];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[CATransaction setCompletionBlock: ^ {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(transition.duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^ {
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
});
}];
self.detailAlertRecuesView = [[[detailAlertRecuesViewController alloc] initWithNibName:@"detailAlertRecuesViewController" bundle:nil] autorelease];
[self.window.rootViewController presentModalViewController:self.detailAlertRecuesView animated:YES];
//[self.window.rootViewController dismissModalViewControllerAnimated:YES];
[self.window makeKeyAndVisible];
/*
self.loadingViewController = [[[LoadingViewController alloc] initWithAlert:@"LoadingViewController" bundle:nil alertid:1807] autorelease];
self.win = self.loadingViewController;
[self.window makeKeyAndVisible];*/
[CATransaction commit];
#endif
} |
Erreur :
Code:
1 2
|
Warning: Attempt to present <detailAlertRecuesViewController: 0x1f5a52b0> on <LoadingViewController: 0x1f58cbf0> whose view is not in the window hierarchy! |