TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2017 |
Maintained by Arthur Ariel Sabintsev, ID>me.
The ID.me WebVerify SDK for iOS is a library that allows you to verify a user's group affiliation status using ID.me's platform. A sample project has been provided to delineate the integration process.
For more information please email us at [email protected] or visit us at http://developer.id.me.
The changelog can be found in CHANGELOG.md
IDmeWebVerify.h
in your ObjC Bridging Header.You must call IDmeWebVerify.initialize(withClientID: String, clientSecret: String, redirectURI: String)
before using the SDK. You can do it in application(didFinishLaunchingWithOptions:)
for example.
import IDmeWebVerify
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
IDmeWebVerify.initialize(withClientID: "<client_id>", clientSecret: "<client_secret>", redirectURI: "<custom_scheme://callback>")
}
}
You should get the parameters <client_id>
, <client_secret>
, <custom_scheme://callback>
at http://developer.id.me.
You must handle the redirect calls from the SDK. For this you have to register your redirectURI's
URL scheme for your app. Go to Project Navigator -> Select your target -> Info -> URL Types -> New and add your redirectURI's scheme in URL Schemes.
Example: if your redirectURI is my_custom_scheme://callback
, enter my_custom_scheme
in URL Schemes.
In your AppDelegate
you must handle the redirectURL when it gets called. You do this by defining the corresponding delegate functions and then calling IDmeWebVerifySDK
to handle the URL.
If your app supports iOS 9 and above add:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = IDmeWebVerify.sharedInstance().application(app, open: url, options: options)
if !handled {
// do something else
}
return handled
}
If your app supports a lower iOS version than 9.0 then you must also add these methods:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let handled = IDmeWebVerify.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
if !handled {
// do something else
}
return handled
}
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
let handled = IDmeWebVerify.sharedInstance().application(app, open: url, options: [:])
if !handled {
// do something else
}
return handled
}
There were several changes introduced in version 4.0. These are some of the major changes you need to take into account when migrating:
IDmeWebVerify.initialize
before using the SDK.verifyUserInViewController:withClientID:redirectURI:scope:withResults
has been removed. You should now call verifyUser(in: UIViewController, scope: String, withTokenResult: IDmeVerifyWebVerifyTokenResults)
and then getUserProfile(withScope: String?, result: IDmeVerifyWebVerifyProfileResults)
in the result callback.IDmeWebVerify.sharedInstance().getAccessToken(withScope: String, forceRefreshing: Bool, results: IDmeVerifyWebVerifyTokenResults)
which includes a callback with the token (refreshed if it had expired) or an error. You should call this method before each of your requests to the ID.me backend.
The most common errors are that the token could not be refreshed and that there is no access token stored for the specified scope
(happens before login).IDmeWebVerify.h
To see a working example you can:
WebVerifySample.xcodeproj
clientID
, clientSecret
, redirectURI
and scope
in ViewController.m
your_custom_scheme
with your redirectURI
in WebVerifySample-Info.plist
-> URL Types
(or through Project Navigator)Verification occurs through a SFSafariViewController to comply with the best practices for OAuth in iOS.
This means the SDK will open Safari for the user to log in.
You must call verifyUser(in: UIViewController, scope: String, withTokenResult: IDmeVerifyWebVerifyTokenResults)
to launch a SFSafariViewController for the user to authenticate. Take care not to call this method while another instance of that verification process is still under way as it will throw an exception.
Internet connectivity is required, as the verificaiton occurs through a webView.