Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Geni SDK for iOS

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 FamilyList
Octocat-spinner-32 GeniSDK
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.rdoc
README.rdoc

Welcome to Geni iOS SDK

This open source iOS library allows you to integrate Geni into your own iOS application. The library is compatible with all iOS devices, including iPhone, iPad and iPod touch.

Getting Started

The SDK is fully self-contained and does not require any additional libraries.

Follow these steps to download the Geni iOS SDK to your computer:

  1. Install git on your computer

  2. Download Geni iOS SDK using the following command:

git clone git@github.com:geni/geni-ios-sdk.git

Sample Application

Before you proceed with your own application integration, try out our sample application. Our sample application demonstrates our authorization mechanism as well as allows you to download your max family.

The sample application is located here:

geni-ios-sdk/FamilyList/FamilyList.xcodeproj

Once you open the project file, make sure you do the following:

  1. Visit www.geni.com/platform/apps and register your application. You will be given your application id and secret.

  2. Open AppDelegate.m and replace YOUR_APPLICATION_ID with the value you got from the previous step.

  3. Open FamilyList-Info.plist and replace YOUR_APPLICATION_ID with the value from the first step.

  4. Run the application and click on the “Connect to Geni” button. Provide your Geni user login and then authorize your application.

  5. Once you authorized your app, you will be taken back to the FamilyList sample application, which will present you with your max family.

Getting Your Application Up And Running In 10 (Relatively) Simple Steps

Follow these instructions to integrate Geni iOS SDK into your application:

Step 1

Open geni-ios-sdk/GeniSDK/GeniSDK.xcodeproj and drag the GeniSDK folder into your own application root. You can choose to either copy the folder into your application or link it as a source folder. If you keep it linked, you will be able to download the latest version of the SDK without having to re-copy the latest changes to your application.

Step 2

Include GeniSDK in your application classes (where you need the Geni functionality):

import "GeniSDK.h"

Step 3

Visit www.geni.com/platform/apps and register your application. You will be given your application id and secret.

Step 4

Instantiate the Geni object:

Geni *geni = [[Geni alloc] initWithAppId:YOUR_APPLICATION_ID];

Replace the YOUR_APPLICATION_ID with the appropriate value you got from step 3. If you are planning to have more than one controller accessing Geni API, it is recommend that you keep the Geni object in your Application Delegate and make your Application Delegate implement the GeniSessionDelegate protocol.

Step 5

Call authorization method to authorize your application:

[geni authorize:self];

The parameter of the authorize method expects an object that implements GeniSessionDelegate. The authorization mechanism uses OAuth framework that takes the user to a Safari web browser, where the user can login and authorize your application. Once the user has authorized your application, the browser will redirect the user back to your application.

Step 6

In order for the iOS device to recognize the redirect call from the Safari browser and launch your application correctly, add the following property to your application's plist file (you can open the file as source code and deal with XML directly):

<key>CFBundleURLTypes</key>
<array>
  <dict>
		<key>CFBundleURLName</key>
		<string></string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>geni[YOUR_APPLICATION_ID]</string>
		</array>
  </dict>
</array>

Replace [YOUR_APPLICATION_ID] with the value you got from step 4. If your application id is 12345, your CFBundleURLSchemes will look like the following:

<string>geni12345</string>

Step 7

When Safari browser redirects users back to your application, it will match the url from the previous step and call the following method in your Application Delegate:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [geni handleOpenURL:url];
}

Make sure you add the above code to your Application Delegate so that Geni client receives the authorization code.

Step 8

Geni client will process the URL it received in the previous step and call one of the following methods on the session delegate you specified in step 5.

- (void) geniDidLogin;

- (void) geniDidNotLogin:(BOOL)cancelled;

At this point you will either have a user that has authorized your application or canceled the action. You can handle each case in the above methods. If the user has authorized your application, you may now call any Geni API methods.

Step 9

You can make calls to the Geni server using any of the following methods:

- (GeniRequest*)requestWithPath:(NSString *)path
                  andDelegate:(id <GeniRequestDelegate>)delegate;

- (GeniRequest*)requestWithPath:(NSString *)path
                    andParams:(NSMutableDictionary *)params
                  andDelegate:(id <GeniRequestDelegate>)delegate;

- (GeniRequest*)requestWithPath:(NSString *)path
                    andParams:(NSMutableDictionary *)params
                andHttpMethod:(NSString *)httpMethod
                  andDelegate:(id <GeniRequestDelegate>)delegate;

For example, the following code will return back the current user JSON object:

[geni requestWithPath:@"user" delegate:self];

All of the calls to the Geni API are made asynchronously using the callback mechanism and a GeniRequestDelegate protocol. GeniRequestDelegate has a number of optional methods, among them:

- (void)request:(GeniRequest *)request didLoad:(id)result;

- (void)request:(GeniRequest *)request didFailWithError:(NSError *)error;

If the request was successful, the “didLoad” method will be called and a call value will be passed as a parameter. If the request failed, then “didFailWithError” will be called instead.

For the above example, your code may look something like this:

- (IBAction) loadCurrentUserInfo: (id) caller {
       [geni requestWithPath:@"user" delegate:self]; 
}

- (void)request:(GeniRequest *)request didLoadResponse:(GeniResponse *)response {

			 NSLog(@"Name: %@", [response valueForKey:@"name"]);

}

Step 10

To logout from Geni, call the following method:

[geni logout:self];

The parameter must be an object that implements the GeniSessionDelegate protocol.

API Documentation

To get more information on available API, please visit www.geni.com/platform/developer/help

Something went wrong with that request. Please try again.