我的应用使用了Touch ID,但如果用户尚未启用它,我目前要求他们手动打开“设置”应用并向下滚动至“Touch ID”项。
有没有办法在我的应用程序中将它们直接链接到下面显示的Touch ID设置页面?
(请注意,我不想在顶层打开“设置”应用,或者按照is it possible to open Settings App using openURL?中的说明打开应用的原生设置页面。)
Cordova插件是理想的,但任何iOS系统调用的文档都会很棒。
遗憾的是,无法打开Touch ID页面。
编辑:这在iOS 10下再次更改,请检查下面的答案。
Apple更改了在“设置”中打开特定菜单的方式。 iOS 10的scheme的值是“App-Prefs:”。但也许它会在下一个版本中改变。
您可以尝试在一个周期中打开不同的URL。请记住,iOS 7中未定义常量UIApplicationOpenSettingsURLString(如果您支持此版本)。
请看一下我的代码。它适用于iOS 10及更低版本。
// UIApplicationOpenSettingsURLString is available since iOS 8.0
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;
}
}
这对我有用:
NSURL* url = [NSURL URLWithString:@"prefs:root=TOUCHID_PASSCODE"];
[[UIApplication sharedApplication] openURL:url];
编辑:我认为这只有效,因为我安装了一个注册了prefs URL方案的应用程序(Launcher)。通过执行以下操作,通过在我的plist中配置CFBundleURLTypes,我在我自己的应用程序中注册了此方案之后,上面只适用于没有安装此应用程序的设备:
target -> Info -> URL Types -> (add) -> URL Schemes = "prefs"