the alfresco ios sdk

37
The Alfresco iOS SDK Gi Lee (Zia Consulting) Peter Schmidt (Alfresco)

Upload: kennan

Post on 03-Feb-2016

62 views

Category:

Documents


0 download

DESCRIPTION

The Alfresco iOS SDK. Gi Lee (Zia Consulting) Peter Schmidt (Alfresco). Alfresco iOS SDK – Intro Who we are. Gi Lee Zia Consulting (Technical Architect) [email protected] Objective-C CMIS library. Peter Schmidt Alfresco Software (Senior iOS Engineer) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Alfresco iOS SDK

The Alfresco iOS SDK

Gi Lee (Zia Consulting)

Peter Schmidt (Alfresco)

Page 2: The Alfresco iOS SDK

Alfresco iOS SDK – Intro Who we are

Gi LeeZia Consulting(Technical Architect)

[email protected]

Objective-C CMIS library

Peter SchmidtAlfresco Software(Senior iOS Engineer)

[email protected]

Alfresco SDK library & samples apps

Page 3: The Alfresco iOS SDK

Alfresco iOS SDK – IntroWhat we will talk about

Gi LeeCMIS library (Apache)•Part of iOS Alfresco SDK

•Architecture & Design

•Code examples

Peter SchmidtAlfresco SDK•How to get and install it

•Architecture & Design

•Code examples

•Demo of Sample app

•How to get support

Page 4: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsIntroducing the library

• Low level API for CMIS

• Static Cocoa Touch Library

• No third-party API’s

• Asynchronous

• AtomPub binding support

Page 5: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsThe Xcode project

CMIS API LibraryCocoa Touch Static Library

DocumentationAppleDoc DocSet

Min. Req.

Min. Req.iOS 5.1iOS 5.1XCode 4.x

XCode 4.x• ARCARC

• BlocksBlocks

Page 6: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsAn open source project

• Open source Objective-C implementation of CMIS

• Apache 2.0 license

• Collaborative project

• Recently accepted by Apache Chemistry

Page 7: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsiOS specificsNaming Convention

• ObjectiveCMIS code prefixed with CMISError Handling

• No exceptions in iOS, use NSError• As per Apple standard:

“NSError object remains nil if method call is successful.” Always check!

Automated Reference Counting• No more retain, release, autorelease on object

Blocks• Used to handle asynchronous

requests & callbacks

Page 8: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsWhat are blocks?

• Closures for Objective-C, C, C++

• Introduced in iOS 4

• Ad hoc functionality that can be passed like parameters

• Good for callbacks!

Page 9: The Alfresco iOS SDK

ObjectiveCMIS – The BasicsAsynchronous handling

Repository

// Completion BlockIf(nil != session){ self.session = session; …}else{ /* error handling */}

CMIS API

Page 10: The Alfresco iOS SDK

ObjectiveCMIS – Design & ArchitectureThe API layers

Client Binding API• Low-Level API• Follows the CMIS

Domain Model• More Control• Clunky to Implement

Client Object API• Object Oriented• Easy to Use• Built-In LinkCache

Page 11: The Alfresco iOS SDK

ObjectiveCMIS – Design & ArchitectureClient API common interface

Page 12: The Alfresco iOS SDK

ObjectiveCMIS - Getting StartedHow do I use it?

Added as a binary + Headers• Simple• Need to generate binary

Added to a Xcode Workspace• Extends workflow scope• Provides full access to source code

Page 13: The Alfresco iOS SDK

ObjectiveCMIS – Getting Started… as a Generated Binary + Headers

1. Execute the script build_universal_lib.sh

2. Add generated build output folder to your project

3. Configure the build target dependency• Link libObjectiveCMIS.a

4. Configure the Target Build Settings• User Header Search Paths =

“$(BUILT_PRODUCTS_DIR)” [recursive]• Other Linker Flags = “-ObjC –all_load”

Page 14: The Alfresco iOS SDK

ObjectiveCMIS – Getting Started… added to an Xcode workspace

1. Open/Create Xcode Workspace

1. Add the ObjectiveCMIS project to the workspace

1. Configure the build target dependency• Link libObjectiveCMIS.a

1. Configure the target Build Settings1. User Header Search Paths =

“$(BUILT_PRODUCTS_DIR)” [recursive]2. Other Linker Flags = “-ObjC –all_load”

2. Configure the project build scheme (optional)

Page 15: The Alfresco iOS SDK

ObjectiveCMIS – Getting StartedIn a nutshell

1. Add ObjectiveCMIS to your project2. Link the library libObjectiveCMIS.a3. Configure the target Build Settings

• User Header Search Paths = “$(BUILT_PRODUCTS_DIR)”

[recursive]• Other Linker Flags = “-ObjC –all_load”

Page 16: The Alfresco iOS SDK

ObjectiveCMIS – Documentation

http://gentlebytes.com/appledoc

Page 17: The Alfresco iOS SDK

ObjectiveCMIS – DocumentationGenerating the documentation

Setup AppleDoc• Clone the source from Github

• https://github.com/tomaz/appledoc

• Install Appledoc using the script install-appledoc.shinstall-appledoc.sh –b /usr/bin/ -t ~/Library/Application\ Support/appledoc

Generate Documentation• Open the ObjectiveCMIS Xcode project • Run the target “Documentation”

Page 18: The Alfresco iOS SDK

ObjectiveCMIS – Code ExampleSetup a CMIS session

// Define session parametersCMISSessionParameters *params = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeAtomPub];

params.atomPubUrl = [NSURL URLWithString:cmisAtompubLocation];params.username = @”devconUser";params.password = @”devconPassword";params.repositoryId = self.repoId;

// Connect session[CMISSession connectWithSessionParameters:sessionParams completionBlock:^(CMISSession *session, NSError *error) { if (session == nil) { // Error handling code goes here // Dig into error object to determine cause } else { // CMISSession successfully connected self.session = session; } }];

Page 19: The Alfresco iOS SDK

ObjectiveCMIS – Code ExampleGet the root collection[self.session retrieveRootFolderWithCompletionBlock: ^(CMISFolder *folder, NSError *error) { if (nil == folder) { // Error handling code goes here // Dig into error object to determine cause } else { /* Folder object is the root */ self.rootFolder = folder; } }];

Page 20: The Alfresco iOS SDK

Objective CMIS – Code ExampleQuery// Create Query Completion Blockvoid(^queryCompBlock)(CMISPagedResult *pagedResult, NSError *error);queryCompBlock = ^(CMISPagedResult *pagedResult, NSError *error){ if (nil == pagedResult) { // Error handling code goes here // Dig into error object to determine cause } else { /* Process the Paged Results */ }};

NSString *queryStr = @"SELECT * FROM cmis:document WHERE CONTAINS('DevCon')";

// Execute Query[self.session query:queryStr searchAllVersions:NO completionBlock:queryCompBlock];

Page 21: The Alfresco iOS SDK

ObjectiveCMISHow do I get the library?

Alfresco / Objective-CMIShttps://github.com/alfresco/Objective-CMIS

Page 22: The Alfresco iOS SDK

Alfresco iOS SDK – The BasicsWhat is included?

Sample Apps

Mobile API LibraryIncluding Objective CMIS

library

Documentation(appledoc docset)

Min. Req.

Min. Req.iOS 5.1iOS 5.1XCode 4.x

XCode 4.x• ARCARC

• JSONJSON

• Storyboards

Storyboards

Page 23: The Alfresco iOS SDK

Alfresco iOS SDK – The BasicsHow do I get the SDK?

• Download it from our website

• https://developer.alfresco.com/mobile

• From our public github repository

• https://github.com/Alfresco/alfresco-ios-sdk

• Online documentation/tutorial

• https://developer.alfresco.com/resources/alfresco/pdf/iOS-SDK-1.0.pdf

Page 24: The Alfresco iOS SDK

Alfresco iOS SDK – The BasicsHow do I install it?1. Unzip alfresco-ios-sdk.zip file

2. Open XCode

3. File menu

4. Add files to…

DONE ✔

Page 25: The Alfresco iOS SDK

Alfresco iOS SDK - Architecture & Design Design Principles

RepositoryAlfresco inthe Cloud

• Session-Service-Model• Session for

connections• Services for requests

between app & server• Model to handle data

• Blocks• To handle

asynchronous behaviour

Asynchronous calls

Page 26: The Alfresco iOS SDK

Alfresco iOS SDK - Architecture & DesignOverall Structure

Page 27: The Alfresco iOS SDK

Alfresco iOS SDK - Architecture & Design Session

Page 28: The Alfresco iOS SDK

Alfresco iOS SDK - Architecture & Design Services

Page 29: The Alfresco iOS SDK

Alfresco iOS SDK – CodingCreate a Session#import “AlfrescoRepositorySession.h”…@property (nonatomic, strong) id<AlfrescoSession> session;…

[AlfrescoRepositorySession connectWithUrl:url username:username password:password parameters:nil completionBlock:^(id<AlfrescoSession>session, NSError *error){

if(nil == session) FAILURE error handlingelse

weakSelf.session = session;}];

Page 30: The Alfresco iOS SDK

Alfresco iOS SDK – CodingBlocks Everywhere•Used in most methods of Alfresco SDK•Used to encapsulate asynchronous REST API/CMIS calls

EXAMPLE•Get the children in the root folder

#import “AlfrescoDocumentFolderService.h”…AlfrescoDocumentFolderService *folderService =

[[AlfrescoDocumentFolderService alloc] initWithSession:self.session];[folderService retrieveChildrenInFolder:self.session.rootFoldercompletionBlock:^(NSArray *children, NSError *error){

if(nil != children){

…<put your code handling folder children here>}

}];

Page 31: The Alfresco iOS SDK

Alfresco iOS SDK – CodingWhat about connecting to Cloud?Alfresco Cloud uses OAuth 2 for authenticating

1.Register with Cloud to get an API key and Secret key

2.Provide both in your APP

3.Alfresco iOS SDK provides a set of helper classes

• AlfrescoOAuthLoginViewController• Connects to login page• Handles the OAuth dance• Returns access/refresh token as part of

AlfrescoOAuthData

Page 32: The Alfresco iOS SDK

Alfresco iOS SDK – CodingCloud OAuth Dance

Page 33: The Alfresco iOS SDK

Alfresco iOS SDK – CodingConnecting to Alfresco in the Cloud#import “AlfrescoCloudSession.h”#import “AlfrescoOAuthData.h”#import “AlfrescoOAuthDataLoginViewController.h”…

AlfrescoOAuthCompletionBlock completionBlock =^void(AlfrescoOAuthData *oauthData, NSError *error){if(nil != oauthData){

[AlfrescoCloudSession connectWithOAuthData:oauthData parameters:nilcompletionBlock:(id<AlfrescoSession>session, NSError *error{

<your session handling goes here> }];

}};

AlfrescoOAuthLoginViewController *controller = [[AlfrescoOAuthLoginViewController alloc] initWithAPIKey:apiKey secretKey:secretKey completionBlock:completionBlock];

[self.navigationController pushViewController:controller animated:YES];

Page 34: The Alfresco iOS SDK

Alfresco iOS SDK – CodingDemo time

Page 35: The Alfresco iOS SDK

Alfresco iOS SDK – The RestWhat about support – CMIS library?

• Apache mailing list• [email protected] • Subscribe & archive:

• http://mail-archives.apache.org/mod_mbox/chemistry-dev/

• Raise tickets in JIRA• https://issues.apache.org/jira/browse/CMIS • Component: objectivecmis• (you’d need an account for that)

• Apache Chemistry website• http://chemistry.apache.org

Page 36: The Alfresco iOS SDK

Alfresco iOS SDK – The RestWhat about support – Alfresco SDK?

• Alfresco Forums• https://forums.alfresco.com • Look for Alfresco Mobile

• Raise tickets in JIRA• https://issues.alfresco.com/jira/browse/MOBSDK• (you need a JIRA account for this)

• Project: Mobile SDK• Components: API• Affects Version: iOS x.x• Assignee: Mobile Team unassigned

• Have Support Agreement? • Contact Support

Page 37: The Alfresco iOS SDK

Alfresco iOS SDK – The RestFeedback, Q&A?

• Feedback• Regarding SDK• Regarding tutorials

• Your Questions answered