[英]unable to redirect to particular screen from local notification in iOS
I have built notification based application in iOS now I am getting issue is that when notification appears on screen, unable to redirect to particular screen containing its data. 我已经在iOS中构建了基于通知的应用程序,现在我遇到的问题是,当通知出现在屏幕上时,无法重定向到包含其数据的特定屏幕。 One thing I have observed is that If I NSLog it,I get all the values of that particular notification but screen does not get load.
我观察到的一件事是,如果我NSLog,我会获得该特定通知的所有值,但屏幕不会得到加载。 Am i missing something while integrating local notification hierarchy code ?
集成本地通知层次结构代码时,我是否缺少任何内容?
Thanks in advance for your help !! 在此先感谢您的帮助 !!
Here is code in Appdelegate. 这是Appdelegate中的代码。
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder"
message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
if([[notification.userInfo valueForKey:@"note"]isEqualToString:@"note"])
{
// nsuserdefault...
NSDateFormatter *dateFormatterN = [[NSDateFormatter alloc] init];
[dateFormatterN setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
NSString *currentTimeN = [dateFormatterN stringFromDate:notification.fireDate];
NSUserDefaults *prefnote=[NSUserDefaults standardUserDefaults];
[prefnote setObject:currentTimeN forKey:@"dateobject"];
[prefnote setObject:@"notification" forKey:@"notification"];
[prefnote synchronize];
NSBundle *bundle = [NSBundle mainBundle];
NSString *storyboardName = [bundle objectForInfoDictionaryKey:@"UIMainStoryboardFile"];
UIStoryboard *storyboardNote = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
UIViewController *vc1Note = [storyboardNote instantiateViewControllerWithIdentifier:@"Home"]; //if you assigned this ID is storyboard
UIViewController *vc2Note = [storyboardNote instantiateViewControllerWithIdentifier:@"AddNote"]; //if you assigned this ID is storyboard
NSArray *controllersNote = @[vc1Note,vc2Note];
UINavigationController *navControllerNote = (UINavigationController *)self.window.rootViewController;
[navControllerNote setViewControllers:controllersNote];
}
}
I have used IF condition as I have 3 categories and based on particular category It will be redirected to different screen. 我使用了IF条件,因为我有3个类别,并且基于特定类别,它将被重定向到其他屏幕。
You have created a new UINavigationController instance and set view controllers in this new navigation controller. 您已经创建了一个新的UINavigationController实例,并在此新的导航控制器中设置了视图控制器。 However you have not presented the nav controller.
但是,您尚未提供导航控制器。
You need to either 你需要
or 要么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.