gpt4 book ai didi

ios - APNS打开应用程序的某个部分

转载 作者:行者123 更新时间:2023-11-29 12:25:11 24 4
gpt4 key购买 nike

我刚刚在我的应用中实现了评论功能。理想情况下,当有人发表评论时,我希望所有收到通知的人都能够滑动推送通知并打开该帖子上的应用。

最佳答案

我假设您想直接打开相关页面。有很多方法可以解决这个问题,这取决于您的应用程序的布局方式。

如果您想在应用程序启动时打开一个内页,您可以通过编程方式触发用户否则需要手动进行的转场。 (这确保了后退/主页按钮的工作,而不是直接加载所需的页面)。这是我自己的一段代码的摘录,您的用例可能不一样,但这就是我所能做的,除非您提供更多详细信息。

- (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;
}

我希望代码是不言自明的。干杯

关于ios - APNS打开应用程序的某个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29352439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com