iOS10 SFSafariViewController not working when alpha is set to 0

后端 未结 4 730
孤独总比滥情好
孤独总比滥情好 2020-12-18 02:12

I\'m using SFSafariViewController to grab user\'s cookie in my app. Here\'s is my code:

SFSafariViewController *safari = [[SFSafariViewController alloc]initW         


        
4条回答
  •  清歌不尽
    2020-12-18 02:57

    New info: Don't do this. The revised App Store guidelines prohibit this practice.

    https://developer.apple.com/app-store/review/guidelines/

    I'll leave this below for posterity: I call the following code from my app delegate's didFinishLaunchingWithOptions.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [self checkCookie];
    }
    
    - (void)checkCookie
    {
        NSURL *url = [NSURL URLWithString:@"http://domainToCheck.com"];
        SFSafariViewController *vc = [[SFSafariViewController alloc] initWithURL:url];
        vc.delegate = self;
    
        UIViewController *windowRootController = [[UIViewController alloc] init];
    
        self.secondWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        self.secondWindow.rootViewController = windowRootController;
        [self.secondWindow makeKeyAndVisible];
        [self.secondWindow setAlpha:0.1];
    
        [windowRootController presentViewController:vc animated:NO completion:nil];
        self.window.windowLevel = 10;
    }
    
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(nonnull NSDictionary *)options
    {
        [self.secondWindow.rootViewController dismissViewControllerAnimated:NO completion:nil];
        self.secondWindow = nil;
        self.window.windowLevel = 0;
    
        return YES;
    }
    

提交回复
热议问题