我希望在用户提供推送通知权限时显示thanku.html
页面(即,当用户点击“确定”按钮以允许通知时)。
此页面只能显示一次。
面临的问题:
thanku.htlml
页面在后台重新加载。 thanku.html
页面。然而,它不应该在重新启动时显示。我编写的代码:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
// For show the thank you page
NSArray *controllers = [SlideNavigationController sharedInstance].viewControllers;
for (id obj in controllers) {
if([obj isKindOfClass:[ViewController class]])
{
ViewController *controller = (ViewController *)obj;
controller.titleOfController = @"Thank you";
controller.urlStr = @"http://www.7dci.com.au/lagarto/thankyou.html";
[controller showAtAppearTime];
[[SlideNavigationController sharedInstance] popToViewController:controller animated:YES];
return;
}
}
ViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:nil ] instantiateViewControllerWithIdentifier:@"ViewController"];
controller.titleOfController = @"Thank you";
controller.urlStr = @"http://www.7dci.com.au/lagarto/thankyou.html";
[controller showAtAppearTime];
[[SlideNavigationController sharedInstance] pushViewController:controller animated:YES];
}
在viewdidload
视图控制器中:
[self showAtAppearTime];
而showAtAppearTime
是:
- (void)showAtAppearTime
{
[webView setDelegate:self];
[self setEmptyWebview];
titleLbl.text = @"saurabh";
if(self.titleOfController.length > 0)
titleLbl.text = self.titleOfController;
[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSString *urlAddress = @"http://7dci.com.au/lagarto/menu.html";
if(self.urlStr.length > 0)
urlAddress = self.urlStr;
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
而setEmptyWebview
是
NSString *urlAddress = @"";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
答案 0 :(得分:0)
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
if(![[[NSUserDefaults standardUserDefaults] objectForKey:@"isFirstTime"] isEqualToString:@"Yes"]){
[[NSUserDefaults standardUserDefaults] setObject:@"Yes" forKey:@"isFirstTime"];
[[NSUserDefaults standardUserDefaults] synchronize];
//Write your required code to set html here
} }
希望这会对你有所帮助