Automatically launch Google Authenticator app on iOS

痞子三分冷 提交于 2019-12-22 09:11:33

问题


Is there a supported way of launching Google Authenticator on iOS?

I want to make it easier for customers to open the app and copy out the time-based code, before pasting it back into my app.

I've empirically discovered that this (Swift) code will launch the app:

UIApplication.sharedApplication().openURL(NSURL(string: "otpauth://")!)

...but I want to know if there is a better, supported way.

Specifically, is the otpauth:// protocol supported without arguments to simply launch the app?


回答1:


Looking at the Git repo for the app it does seem like they have registered the Custom URL Schemes for bot otpauth and totp

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

And here

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

And here is the documentation on how exactly to build the url:

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

After you form them correctly and get your app and the Google Authenticator app on the same device you would just need to test.



来源:https://stackoverflow.com/questions/32043500/automatically-launch-google-authenticator-app-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!