【问题标题】:Open app from App Store not the same as in board从 App Store 打开应用程序与在板中打开应用程序不同
【发布时间】:2021-02-04 09:07:40
【问题描述】:

我有一个“条款和条件”控制器,我在第一次启动应用程序时代表,但是当第一次从 App Store 页面打开应用程序时,没有显示“条款和条件”控制器 - 仅在我关闭后应用程序并从设备本身(不是 App Store 页面)重新打开它,然后显示控制器。

这段代码来自启动的屏幕控制器:

- (void)viewDidLoad {

    [self agreedToServerTerms];

} 

- (void)agreedToServerTerms {
    [[HttpUtils instance] httpRequest:TERMS_AGREEMENT_URL :params completionHandler:^(NSData *data, NSError *error) {
        @try {
            bool acceptTerms = false;
            if (error) {
                [Utils log:[NSString stringWithFormat:@"agreedToServerTerms error=%@", error]];
            } else {
                NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
                if (!error) {
                    acceptTerms = [jsonData.allValues[0] boolValue];
                    if (!acceptTerms) {
                        TermsAndConditionController *tac = [[TermsAndConditionController alloc] initWithNibName:@"TermsAndConditionController" bundle:nil];
                        tac.delegate = self;
                        [[SlideNavigationController sharedInstance] pushViewController:tac animated:false];
                    }
                    else {
                        [self performSelectorInBackground:@selector(initialApp) withObject:nil];
                    }

                    
                } else {
                    [Utils log:[NSString stringWithFormat:@"parsing jsonData error = %@" ,error]];
                    
                }
            }
        } @catch (NSException *e) {
            [Utils log:[NSString stringWithFormat:@"Exception occurred: %@, %@", e, [e userInfo]]];
        } 

    }];
}

来自应用委托:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 LaunchScreenController *bbp = [[LaunchScreenController alloc] initWithNibName:@"LaunchScreenController" bundle:nil];
[[SlideNavigationController sharedInstance] pushViewController:bbp animated:YES];
if (_launchedURL) {
    bbp.launchedURL = _launchedURL;
}

[self.window addSubview:bbp.view];
}

【问题讨论】:

  • 可能显示您如何启动应用程序或如何启动此特定控制器
  • 已添加,我也在 ipad 中检查过,但从 App Store 打开时应用会按预期打开
  • 我认为你需要做一些不同的事情 - 如何取决于你的应用程序的其余部分。我认为您不应该在此处向窗口添加子视图。相反,在显示的第一个 VC 中,在那里执行一些检查,然后显示您的 TnC VC。我将发布一个示例...

标签: ios objective-c uiviewcontroller


【解决方案1】:

我如何做几乎完全相同的事情。我认为你需要修改你的,可能会有所不同,但这可能会有所帮助。

在我的应用程序显示的第一个 VC 中,在其 viewWillAppear 消息中,我有以下代码

    // Terms of use
    if ( [NSUserDefaults.standardUserDefaults integerForKey:@"tou"] != 20170614 )
    {
        [self performSegueWithIdentifier:@"tou" sender:nil];
        [NSUserDefaults.standardUserDefaults setInteger:20170614 forKey:@"tou"];
    }

这使用用户默认值来记录使用条款是否曾经出现过,如果出现过,它会将@"tou" 标记为任意值。在您的情况下,您可以在控制器中设置逻辑,并且只有在用户接受后才标记它。

这需要在情节提要中有一个名为 @"tou" 的 segue,它将显示您的 T&C 控制器,如果用户不同意,您可能需要阻止退出,但如果用户不同意,我们的想法是远离您的第一个 VC同意向用户展示 T&C,而不是像您目前所做的那样将其注入到应用程序委托中。

【讨论】:

    猜你喜欢
    • 2019-12-24
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 2011-11-21
    • 2011-03-08
    相关资源
    最近更新 更多