How to automatically launch the Google Authenticator iOS app and send data (issuer, user, secret) from Objective-c code?
This question partially solves for Swift but looking for Objective-c. Automatically launch Google Authenticator app on iOS
As of iOS 9, the first thing you will need to do is whitelist the url scheme by adding this to your Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>otpauth</string>
</array>
Then to launch into Google Authenticator all you should need to do is this:
NSString *otpString = @"otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example";
NSURL *otpURL = [NSURL URLWithString:otpString];
if ([[UIApplication sharedApplication] canOpenURL:otpURL]) {
[[UIApplication sharedApplication] openURL:otpURL];
}
• Useful page for generating Google Authenticator URLs.
• You can look at Google's internal code for parsing the URLs here.