Ios APNS打开应用程序的特定部分
我刚刚在我的应用程序中实现了一个评论功能。理想情况下,当有人留下评论时,我希望所有收到通知的人都能够滑动推送通知并打开该帖子上的应用程序。我假设您希望直接打开相关页面。有很多方法可以做到这一点,这取决于应用程序的布局 如果你想在应用程序启动时打开一个内部页面,你可以通过编程方式触发用户需要手动创建的序列。(这确保了后退/主页按钮可以正常工作,而不是直接加载所需页面)。 这里是我自己的一段代码的摘录,您的用例可能不同,但除非您提供更多细节,否则我只能这样做Ios APNS打开应用程序的特定部分,ios,objective-c,xcode,apple-push-notifications,Ios,Objective C,Xcode,Apple Push Notifications,我刚刚在我的应用程序中实现了一个评论功能。理想情况下,当有人留下评论时,我希望所有收到通知的人都能够滑动推送通知并打开该帖子上的应用程序。我假设您希望直接打开相关页面。有很多方法可以做到这一点,这取决于应用程序的布局 如果你想在应用程序启动时打开一个内部页面,你可以通过编程方式触发用户需要手动创建的序列。(这确保了后退/主页按钮可以正常工作,而不是直接加载所需页面)。 这里是我自己的一段代码的摘录,您的用例可能不同,但除非您提供更多细节,否则我只能这样做 - (BOOL) navigateToR
- (BOOL) navigateToRespectiveSectionforPushNot:(NSDictionary*)pushNot
{
id rootVC = self.window.rootViewController;
NSLog(@"ROOT CLASS : %@", [rootVC class]);
if ([rootVC isKindOfClass:[SWRevealViewController class]])
{
NSLog(@"Root Class looking good... mission Navigate!!");
SWRevealViewController *homeVC = (SWRevealViewController*) rootVC;
NSString *category = [[pushNot objectForKey:pushPayloadKeyaps] objectForKey:pushPayloadKeyCategory];
NSString *subCat = [[pushNot objectForKey:pushPayloadKeyaps] objectForKey:pushPayloadKeySubCategory];
NSLog(@"category : %@ , subcat : %@",category,subCat);
//The code for the page to which i'm supposed to navigate to is contained in the push notification payload
if ([category isEqualToString:pushCategoryItemChat])
{
[homeVC.rearViewController performSegueWithIdentifier:@"chatPush" sender:nil];
UINavigationController *nc = (UINavigationController*)homeVC.frontViewController;
NSLog(@"FrontView Class : %@",[nc.viewControllers[0] class]);
UITableViewController *tvc = (UITableViewController*)nc.viewControllers[0];
NSDictionary *send = @{chatPushTargetUserId:subCat,chatPushTargetUserName:@"",chatPushTargetUserImage:@""};
[tvc performSegueWithIdentifier:@"seguePushDemoVC" sender:send];
return YES;
}
//communityPush historyPush
else if ([category isEqualToString:pushCategoryItemCommunity])
{
if ([subCat isEqualToString:pushSubCatItemNewRequest])
{
[homeVC.rearViewController performSegueWithIdentifier:@"communityPush" sender:nil];
return YES;
}
else if ([subCat isEqualToString:pushSubCatItemAccepted])
{
[homeVC.rearViewController performSegueWithIdentifier:@"communityPush" sender:nil];
return YES;
}
}
else if ([category isEqualToString:pushCategoryItemHistory])
{
[homeVC.rearViewController performSegueWithIdentifier:@"historyPush" sender:nil];
return YES;
}
}
else
{
UIAlertView *whoa = [[UIAlertView alloc] initWithTitle:@"WHOA!!" message:@" That wasn't supposed to happen. You are not even logged in. Call 911..." delegate:nil cancelButtonTitle:@"mmKay.." otherButtonTitles:nil, nil];
[whoa show];
}
return NO;
}
我希望代码是不言自明的。干杯所以,。。。你尝试过什么,失败了什么,它是如何失败的,你对它的具体问题是什么?