Automatically launch Google Authenticator app on i

2019-05-18 04:15发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-05-18 04:27

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.

查看更多
登录 后发表回答