Name: ios-sdk
Owner: Clever
Description: Clever iOS SDK
Created: 2015-04-10 03:51:54.0
Updated: 2017-09-14 10:22:56.0
Pushed: 2018-05-22 14:49:31.0
Homepage: null
Size: 569
Language: Objective-C
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
CleverSDK is a simple iOS library that makes it easy for iOS developers to integrate Clever Instant Login into their application. You can read more about integrating Clever Instant Login in your app here.
You can create an iOS redirect URL by going to https://apps.clever.com/partner/applications and clicking View / Edit on your application.
Click on the “Enable iOS Platform” button (contact Clever Support if option is not available).
You will then get access to a client ID and redirect URI you can use for your iOS app.
You can also set a “fallback URL” where users will be redirected if they don't have your app installed.
Once you have the custom redirect URL, add it to your application as a custom URL scheme. If you are not sure how to do so, you can read this tutorial for help.
Finally, add com.clever
to your LSApplicationQueriesSchemes in your Info.plist, so you can redirect directly to the Clever app.
More information on LSApplicationQueriesSchemes can be found here.
Once the app configuration has been updated, add the following code to the application:didFinishLaunchingWithOptions:
method in AppDelegate.m:
OOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Start the CleverSDK with your client
// Do not forget to replace CLIENT_ID with your client_id
[CLVOAuthManager startWithClientId:@"CLIENT_ID" successHandler:^(NSString * _Nonnull accessToken) {
NSLog(@"success");
} failureHandler:^(NSString * _Nonnull errorMessage) {
NSLog(@"failure");
}];
// To support iOS 9/10, you must set the UIDelegate to the UIViewController
// that will be displayed when the user is logging in.
MyLoginViewController *vc = [[MyLoginViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = vc;
[CLVOAuthManager setUIDelegate:vc]
// Alternatively, you can initialize CLVOAuthManager without success/failure blocks and instead use the delegate pattern.
// See "Delegate Pattern" below for handling completion when using the delegate pattern
// [CLVOAuthManager startWithClientId:@"CLIENT_ID"];
// [CLVOAuthManager setDelegate:self];
Besides the above change, you also need to add some code to handle the iOS redirect URI.
This is done by implementing the application:openURL:sourceApplication:annotation:
method of the AppDelegate:
OOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
// Clever's URL handler
return [CLVOAuthManager handleURL:url sourceApplication:sourceApplication annotation:annotation];
You can also set up a Log in with Clever Button. In the UIViewController
set as the UIDelegate, add the following code to the viewDidLoad
method:
reate a "Log in with Clever" button
nButton = [CLVLoginButton createLoginButton];
f.view addSubview:loginButton];
The button is instantiated with a particular width and height.
You can update the width of the button by calling setWidth:
method on the button:
f.loginButton setWidth:300.0];
If you are using the delegate pattern instead of completion blocks, add the following method to your AppDelegate.m:
f non-null blocks are provided, signInToClever:withError: will not be called
oid)signInToClever:(NSString *)accessToken withError:(NSString *)error {
if (error) {
// error
}
// success
To run the example project, clone the repo, and run pod install
from the Example/SimpleLogin directory first.
CleverSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:
"CleverSDK"
Apache 2.0