【问题标题】:How to open the TouchID page in settings page?如何在设置页面打开 TouchID 页面?
【发布时间】:2017-12-03 21:21:16
【问题描述】:

我是 Objective-C 的新手。我想在 iPhone 设置页面中打开 TouchID 页面,但我的代码只是在在线公共源中打开设置页面。我写了下面的代码。

======打开iPhone设置页面=======

if (&UIApplicationOpenSettingsURLString != NULL)
    {
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        [[UIApplication sharedApplication] openURL:url];
        NSLog(@"&UIApplicationOpenSettingsURLString != NULL");
    }
    else
    {
        // Present some dialog telling the user to open the settings app.
        NSLog(@"&UIApplicationOpenSettingsURLString == NULL");
    }

如何修改代码来解决这个问题?

【问题讨论】:

    标签: ios objective-c iphone


    【解决方案1】:

    编辑:

    此解决方案不再适用于 iOS 11+


    在 iOS 10 之前你不能这样做。

    话虽如此,您必须“找出”网址是什么。

    你可以试试这个代码:

    // URL to open general settings in case the TouchID one was not found.
    NSString * defaultSettingsStr = ( &UIApplicationOpenSettingsURLString != NULL ? UIApplicationOpenSettingsURLString : @"prefs:root" );
    
    // Array of possible URLs, differ in various iOS versions
    NSArray * urlStrs = @[@"App-Prefs:root=TOUCHID_PASSCODE",
                     @"Prefs:root=TOUCHID_PASSCODE",
                     defaultSettingsStr];
    
    for (NSString * urlStr in urlStrs) {
       NSURL * url = [NSURL URLWithString:urlStr];
    
       if ([[UIApplication sharedApplication] canOpenURL:url]) {
           // openURL is deprecated since iOS 10
           [[UIApplication sharedApplication] openURL:url];
           break;
       }
    }
    

    【讨论】:

    • "App-Prefs:root=TOUCHID_PASSCODE" 在 iOS 11 上不起作用。您知道其他解决方案吗?
    • 据我了解,在 iOS 11 上,除了“设置”主页面外,其他任何地方都无法访问。 (所以不再去任何小节了)
    • 此解决方案将导致您的应用被审核流程拒绝 - App-Prefs:root 被视为私有 API。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    相关资源
    最近更新 更多