Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

iOS SDK for the Kloudless API

iOS SDK for the Kloudless API

Getting Started Using the KloudlessSDK for iOS:

Requirements:

  1. You need the 4.2 version of the iPhone SDK. The version of your Xcode should be at least 3.2.5.
  2. You need to have registered as a Kloudless app at https://developers.kloudless.com. You should have an App key and API Key.

Note: The SDK is designed to work with iOS versions 9.0 and above.

Building and using the example app:

  1. Open the project file in examples/KTester/KTester.xcodeproj
  2. Fill in the values for appId in KTesterAppDelegate.m application:didFinishLaunchingWithOptions:
  3. Configure a Redirect URI (KTester://kloudless.com/callback ) in your Application Details (https://developers.kloudless.com/applications/*/details) page of the Developer portal.
  4. Make sure the build is set to Simulator. This setting should be near the top-left corner of Xcode.
  5. Build and Run app
  6. Once running, you can test functionalities of the API without getting errors.

If you cannot run the app without getting errors, please contact us at support@kloudless.com.

Authorizing Users without the SDK.

  1. The Kloudless SDK will use the SFSafariViewController to handle authentication and store the values within the KAuth object.
  2. However, if you want to handle authentication on your own please follow the following steps.
  3. Follow the steps for implicit OAuth flow: https://developers.kloudless.com/docs/v1/authentication#header-implicit-grant-flow
  4. Register a custom URL scheme in the Kloudless developer portal.
  5. Add this custom URL scheme to your CFBundle type in your Info.plist.
  6. Initialize an SFSafariViewController with the implicit oauth url.
  7. The access token will be returned in the url fragment. KTester includes an example code snippet to parse the access token.

Adding the KloudlessSDK.Framework to a Third-Party Application

View a sample project that shows the result of following these steps in the examples/ directory.

This is the easy part (and what your third-party developers will have to do). Simply drag the .framework to your application's project, ensuring that it's being added to the necessary targets.

Import your framework header and you're kickin' ass.

#import <KloudlessSDK/KloudlessSDK.h>

Resources

If you're distributing resources with your framework then you will also send the .bundle file to the developers. The developer will then drag the .bundle file into their application and ensure that it's added to the application target.

Documentation

See the Kloudless API Docs for the official reference. You can obtain an API Key at the Developer Portal.

Here is a basic example of the most important methods in the Kloudless iOS SDK.

Step 1. Modifying the delegate with your App Id.

// Insert your App ID from your Kloudless App Details.
NSString *appId = @"YOUR APP ID HERE";

// The KAuth object keeps track of all accounts and account keys per application.
KAuth* auth = [[KAuth alloc] initWithAppId:appId];

// KAuthDelegate methods allow you to handle re-authentication
auth.delegate = self;

// Use a class instance for referencing the KAuth object.
[KAuth setSharedAuth:auth];

Step 2. Authenticate users and create a client.

// Start the authentication from a View Controller
[[KAuth sharedAuth] authFromController: self];

...
// This will be called when the authentication finishes
// TODO: move to a delegate method
- (void)viewDidAppear(BOOL)animated
{
// The account will be linked with all accounts and keys.
// Grab an accountId and accountKey.
KAuth *auth = [KAuth sharedAuth];
if ([auth isLinked]) {
    NSString *accountId = [[auth accountIds] objectAtIndex:0];
    NSString *accountKey = [auth keyForAccountId:accountId];

    // Create a client for a specific account key
    KClient *accountClient = [[KClient alloc] initWithKey:accountKey accountId:accountId];
    // Set the client delegate to handle selectors
    client.delegate = self;
}

Step 3. Make a few API requests from the client. *Note: Kloudless SDK uses callback selectors.

// See all the files/folders in an account by passing in the folderId
NSString *folderId = @"root";
[client getFolderContents:folderId];

...
// This is the callback selector called from the KClient Delegate on success.
- (void)restClient:(KClient*)client getFolderContentsLoaded:(NSDictionary *)folderContents
{
    NSLog(@"Folder Contents: %@", folderContents);
}

// This is the callback selector called from the KClient Delegate on failure.
- (void)restClient:(KClient*)client getFolderContentsFailedWithError:(NSError*)error
{
    NSLog(@"Error: %@", error);
}

UPDATES

  • 2017/04 - updated SDK to use SFSafariViewController and implicit auth
  • 2016/08 - updated SDK to Kloudless v1
  • 2014/09 - updated SDK with new methods, modified auth controller
  • 2014/04 - added initial Example project

TODO

  • More Tests!
  • Refactor multiple account id / key management
  • Adding additional examples

About

The iOS SDK for the Kloudless Platform

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.