Install with Xcode

This guide describes integrating Social Login without User Registration into your iOS App. For a description of integration steps for registration see Registration > Install with Xcode.

Prerequisites

For applications that use Social Login only, you need to have these elements in place before you begin.

Gather Configuration Details

Configure Identity Providers on the Dashboard

Make sure your desired set of social identity providers is configured in the Dashboard.

Note: Configuring the providers themselves is a separate step from configuring which providers are enabled for the library.

Configure the Providers Used in the iOS Library

While signed in to the dashboard go to the Social Login configuration wizard (in the drop-down menus, under Deployment -> Engage for iOS). Follow the wizard and use it to configure the providers to use for authentication and social sharing from the iOS library.

Retrieve your Application ID

You will also need your Application ID from the Dashboard. This is located at Manage Engage App > Settings > App Info.

Add the Library to the Xcode Project

  1. Follow the Xcode setup instructions here, but skip generating the Registration User Model.
  2. Remove the JRCapture project group from your project.

Choose an Delegate Class and Initialize the Library

Select the class you will use to receive callbacks from the library. This is called your delegate. The delegate should be persistent—that is, it will not be dealloced during the course of your app’s lifetime—and it should be a singleton. Your app’s AppDelegate is a good choice to start with.

In the interface of your chosen delegate class import the header: #import "JREngage.h", and conform to the JREngageSigninDelegate and JREngageSharingDelegate protocols:

@interface AppDelegate : UIResponder

In your delegate’s implementation, during its initialization, (or from elsewhere in your app’s initialization), call the JREngage initialization method, for example from from your AppDelegate’s -application:didFinishLaunchingWithOptions::

[JREngage setEngageAppId:@"" tokenUrl:@"" andDelegate:yourEngageDelegate];

Stub out these two delegate message implementations in your delegate:

- (void)authenticationDidReachTokenUrl:(NSString *)tokenUrl withResponse:(NSURLResponse *)response
andPayload:(NSData *)tokenUrlPayload forProvider:(NSString *)provider
{
NSLog(@"%@", [response description]);
}

- (void)authenticationDidSucceedForUser:(NSDictionary *)authInfo forProvider:(NSString *)provider
{
NSLog(@"%@", [authInfo description]);
}

Social Sign-In

A Social Login authentication is only meaningful in the context of authenticating your mobile app to something. If you are unsure of what your users should be signing into, then User Registration may be a better solution.

To start authentication send the showAuthenticationDialog message to the JREngage class:

[JREngage showAuthenticationDialog];

You will receive your authentication token URL’s response in the authenticationDidReachTokenUrl:... message. When received you will have access to the body of the response, as well as the headers, which frequently contain session cookies used to coordinate the app’s session with your web server. Parsing your authentication token URL’s response for session establishing information, or retrieving session cookies from the header, is your app’s responsibility.

For guidance implementing your web-server’s authentication token URL, see Authentication-Token-URL.md.

Good to Know

The first time your application uses JREngage on any device, the library contacts Janrain servers to retrieve your application’s configuration information. After downloading, the library caches this information. The library updates the cache only when the information changes (for example, when you add or remove a provider). The Library checks for updates after it initializes.

While you can initialize the JREngage library immediately before you call one of the show... methods, understand that your users may encounter our loading screen while the library contacts the Janrain servers.