在 iOS 上自动启动 Google Authenticator 应用

Dan*_*iel 5 ios google-authenticator

是否有支持在 iOS 上启动 Google 身份验证器的方式?

我想让客户更轻松地打开应用程序并复制基于时间的代码,然后再将其粘贴回我的应用程序。

我凭经验发现这个(Swift)代码将启动应用程序:

UIApplication.sharedApplication().openURL(NSURL(string: "otpauth://")!)
Run Code Online (Sandbox Code Playgroud)

...但我想知道是否有更好的支持方式。

具体来说,是否支持没有参数的 otpauth:// 协议来简单地启动应用程序?

Die*_*kim 3

查看该应用程序的 Git 存储库,似乎他们已经为机器人注册了自定义 URL 方案,otpauth并且totp

https://github.com/google/google-authenticator/blob/bd50d15c348a978c314d2b30e586fbc562096223/mobile/ios/OTPAuth-Info.plist#L42

和这里

https://github.com/google/google-authenticator/blob/bd50d15c348a978c314d2b30e586fbc562096223/mobile/ios/Classes/OTPAuthURL.h#L23

以下是有关如何准确构建 url 的文档:

https://github.com/google/google-authenticator/wiki/Key-Uri-Format

正确形成它们并在同一设备上获取您的应用程序和 Google Authenticator 应用程序后,您只需要进行测试。