SlideShare una empresa de Scribd logo
1 de 6
| Build a Mobile Experience

www.innovationm.com

Dropbox Integration in iOS

Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com
| Build a Mobile Experience

www.innovationm.com

Dropbox Integration in iOS
In this tutorial we will learn- how to integrate Dropbox with iOS applications. Let us take
an example of iOS application. We will be talking about the following:
1. Uploading the files from iOS App to Dropbox
2. Downloading files from Dropbox
3. Browsing the Folder / Files structure of Dropbox.
There are mainly two types of APIs for Dropbox integration.


Core API – For Uploading, downloading and browsing the file system



Sync API – When there are some changes done in the files / folder then it will help
in syncing-up to other devices.

Core API
Registering the application on Dropbox and linking in the App
1. Register Application with DropBox - To register your application with Dropbox, you
need to go on Dropbox App Console and follow these steps.


Select “Create App” on App Console.



Select type of app and type of data which we want to save on dropbox.



Give a unique name to your Application.



Now your app created. It will give you “App key” and “AppSecret key”.

2. Linking iOS App with Dropbox - Download Dropbox SDK and add it your iOS
Application. In info.plist URI scheme there is need of adding an item “db-APP_KEY”.
In place of “APP KEY” we will put the App key which we get in first step. First you
have to create the DBSession object for your app:

Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com
| Build a Mobile Experience

www.innovationm.com

#import <DropboxSDK/DropboxSDK.h>
DBSession* dbSession =
[[[DBSession alloc]
initWithAppKey:@"APP_KEY" // add here app key
appSecret:@"APP_SECRET" // add here app secret key
root:ACCESS_TYPE] // either kDBRootAppFolder or kDBRootDropbox
autorelease];
[DBSession setSharedSession:dbSession];

Somewhere in your app add an event to launch the authentication process:
- (void)didPressLink {
if(![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] link];
}
}

Now, we need to add the following code to our application delegate in order to complete
the authentication process.
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url {
if([[DBSession sharedSession] handleOpenURL:url]) {
if([[DBSession sharedSession] isLinked]) {
NSLog(@"App linked successfully!");
// At this point you can start making API calls
}
return YES;
}
// Add whatever other url handling code your app requires here
return NO;
}

Browse Folder and Files of Dropbox
All methods on DBRestClient are asynchronous, meaning they don’t immediately return
the

data

they

are

meant

to

load.

Each

method

has

at

least

two

corresponding DBRestClientDelegate methods, that get called when a request either
succeeds or fails. We can list contents of folder by making the following call
[[self restClient] loadMetadata:@"/"];
Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com
| Build a Mobile Experience

www.innovationm.com

The REST client will then call your delegate with one of the following call backs:
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
if(metadata.isDirectory) {
NSLog(@"Folder '%@' contains:", metadata.path);
for(DBMetadata *file in metadata.contents) {
NSLog(@"t%@", file.filename);
}
}
}
- (void)restClient:(DBRestClient *)client
loadMetadataFailedWithError:(NSError*)error {
NSLog(@"Error loading metadata: %@", error);
}

Downloading file from Dropbox
Now that we know what files are available it’s time to download one.
[[self restClient] loadFile:dropboxPath intoPath:localPath]

To find out if the file download succeeds or fails you need to implement the
following DBRestClientDelegatemethods:
- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)localPath {
NSLog(@"File loaded into path: %@", localPath);
}
- (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error {
NSLog(@"There was an error loading the file - %@", error);
}

Uploading file to Dropbox
After Downloading we can do with it whatever we want. Now next chalenge is how we
can upload a new file on dropbox to share it with other devices & people. Uploading is
as simple as downloading:

Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com
| Build a Mobile Experience

www.innovationm.com

NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
NSString *filename = @"Info.plist";
NSString *destDir = @"/";
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:nil fromPath:localPath];

To see all the operations that are available and the corresponding callback methods
look at the DBRestClient.h file in the SDK. Here are the delegate methods that you
should implement to get the results of the upload call:
-(void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath
from:(NSString*)srcPath metadata:(DBMetadata*)metadata {
NSLog(@"File uploaded successfully to path: %@", metadata.path);
}
- (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error);
}

Sync API
The Sync API takes care of syncing all your data with Dropbox through a familiar, file
system-like interface. It’s like giving your app its own, private Dropbox client. Here we
can proceed with the same steps of linking account as in case of core API. Once app is
linked we can create a file system object.
Syncing of account mainly needs when any change in Dropbox data need to update in
all linking devices & people. So we have to implement the “Change Observer” in the
program.
Observing Changes - A DBFile object is created and is associated with a specific
version of that file. You can check whether it is cached and can be read immediately by
using the status property. If it is not cached, the -readString: call will wait while it

Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com
| Build a Mobile Experience

www.innovationm.com

downloads. If you don’t want to wait, you can use an observer to track its download
progress.
DBFileStatus *status = file.status;
if (!status.cached) {
[self.file addObserver:self block:^() {
// Check file.status and read if it's ready
}];
// Check if the status.cached is now YES to ensure nothing
// was missed while adding the observer
}

You can also check if the version you have is the most recent version of the file with
its newerStatus property. If the file is the latest version, this will be nil. If not, it will return
the sync status for the newest version of the file. When a file is open, the Sync API will
automatically

download

newer

versions

of

the

file

as

they

are

available

and newerStatus will include the download progress. Once a newer version is
downloaded, newerStatus.cached will be set. Then you can call -[DBFile update:] to
update the open file to the newest version.
In addition to a single file, you can also listen to changes to all files in a folder by using
the [DBFilesystem addObserver:forPathAndChildren:] method.

Corporate Office:
InnovationM Mobile Technologies
E-3 (Ground Floor), Sector-3, Noida 201301 (India)
t: +91 8447 227337 | e: info@innovationm.com

Más contenido relacionado

Destacado

Cookpad 24 contest 2012
Cookpad 24 contest 2012Cookpad 24 contest 2012
Cookpad 24 contest 2012R. Ayakix
 
азиза ахметова+протезы+инвалиды
азиза ахметова+протезы+инвалидыазиза ахметова+протезы+инвалиды
азиза ахметова+протезы+инвалидыАнара Исакаева
 
12-Qualification-E
12-Qualification-E12-Qualification-E
12-Qualification-ESocheata Oum
 
Curso de comunicación
Curso de comunicaciónCurso de comunicación
Curso de comunicaciónleonidherrera
 
Λαϊκισμός
ΛαϊκισμόςΛαϊκισμός
Λαϊκισμόςchavalesnick
 
Λαϊκότητα
ΛαϊκότηταΛαϊκότητα
Λαϊκότηταsokaniak
 
The_Shell_Edition_7 Copy
The_Shell_Edition_7 CopyThe_Shell_Edition_7 Copy
The_Shell_Edition_7 Copybenjaminhaslem
 
10 маркетинговых предсказаний на 2017 год
10 маркетинговых предсказаний на 2017 год10 маркетинговых предсказаний на 2017 год
10 маркетинговых предсказаний на 2017 годmfive
 
Lentera News edisi September 2015 | Bijak Kata Bijak Berbagi
Lentera News edisi September 2015 | Bijak Kata Bijak BerbagiLentera News edisi September 2015 | Bijak Kata Bijak Berbagi
Lentera News edisi September 2015 | Bijak Kata Bijak BerbagiAnanta Bangun
 
Lentera news ed. #22 Maret 2016
Lentera news ed. #22 Maret 2016Lentera news ed. #22 Maret 2016
Lentera news ed. #22 Maret 2016Ananta Bangun
 
Lentera news ed.#23 April 2016
Lentera news  ed.#23 April 2016Lentera news  ed.#23 April 2016
Lentera news ed.#23 April 2016Ananta Bangun
 

Destacado (12)

Cookpad 24 contest 2012
Cookpad 24 contest 2012Cookpad 24 contest 2012
Cookpad 24 contest 2012
 
азиза ахметова+протезы+инвалиды
азиза ахметова+протезы+инвалидыазиза ахметова+протезы+инвалиды
азиза ахметова+протезы+инвалиды
 
12-Qualification-E
12-Qualification-E12-Qualification-E
12-Qualification-E
 
Curso de comunicación
Curso de comunicaciónCurso de comunicación
Curso de comunicación
 
Λαϊκισμός
ΛαϊκισμόςΛαϊκισμός
Λαϊκισμός
 
Habilidades de comunicacion para emprendedores
Habilidades de comunicacion para emprendedoresHabilidades de comunicacion para emprendedores
Habilidades de comunicacion para emprendedores
 
Λαϊκότητα
ΛαϊκότηταΛαϊκότητα
Λαϊκότητα
 
The_Shell_Edition_7 Copy
The_Shell_Edition_7 CopyThe_Shell_Edition_7 Copy
The_Shell_Edition_7 Copy
 
10 маркетинговых предсказаний на 2017 год
10 маркетинговых предсказаний на 2017 год10 маркетинговых предсказаний на 2017 год
10 маркетинговых предсказаний на 2017 год
 
Lentera News edisi September 2015 | Bijak Kata Bijak Berbagi
Lentera News edisi September 2015 | Bijak Kata Bijak BerbagiLentera News edisi September 2015 | Bijak Kata Bijak Berbagi
Lentera News edisi September 2015 | Bijak Kata Bijak Berbagi
 
Lentera news ed. #22 Maret 2016
Lentera news ed. #22 Maret 2016Lentera news ed. #22 Maret 2016
Lentera news ed. #22 Maret 2016
 
Lentera news ed.#23 April 2016
Lentera news  ed.#23 April 2016Lentera news  ed.#23 April 2016
Lentera news ed.#23 April 2016
 

Más de InnovationM

How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blinkInnovationM
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native appsInnovationM
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changesInnovationM
 
Understanding of react fiber architecture
Understanding of react fiber architectureUnderstanding of react fiber architecture
Understanding of react fiber architectureInnovationM
 
Automatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swiftAutomatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swiftInnovationM
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...InnovationM
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?InnovationM
 
React – Let’s “Hook” up
React – Let’s “Hook” upReact – Let’s “Hook” up
React – Let’s “Hook” upInnovationM
 
Razorpay Payment Gateway Integration In iOS Swift
Razorpay Payment Gateway Integration In iOS SwiftRazorpay Payment Gateway Integration In iOS Swift
Razorpay Payment Gateway Integration In iOS SwiftInnovationM
 
Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swiftInnovationM
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootInnovationM
 
Basic fundamental of ReactJS
Basic fundamental of ReactJSBasic fundamental of ReactJS
Basic fundamental of ReactJSInnovationM
 
Basic Fundamental of Redux
Basic Fundamental of ReduxBasic Fundamental of Redux
Basic Fundamental of ReduxInnovationM
 
Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )InnovationM
 
Serialization & De-serialization in Java
Serialization & De-serialization in JavaSerialization & De-serialization in Java
Serialization & De-serialization in JavaInnovationM
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8InnovationM
 
How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?InnovationM
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For AndroidInnovationM
 

Más de InnovationM (20)

How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Capture image on eye blink
Capture image on eye blinkCapture image on eye blink
Capture image on eye blink
 
Mob x in react
Mob x in reactMob x in react
Mob x in react
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
 
Android 8 behavior changes
Android 8 behavior changesAndroid 8 behavior changes
Android 8 behavior changes
 
Understanding of react fiber architecture
Understanding of react fiber architectureUnderstanding of react fiber architecture
Understanding of react fiber architecture
 
Automatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swiftAutomatic reference counting (arc) and memory management in swift
Automatic reference counting (arc) and memory management in swift
 
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
Firebase crashlytics integration in iOS swift (dSYM File Required Problem Res...
 
How prototype works in java script?
How prototype works in java script?How prototype works in java script?
How prototype works in java script?
 
React – Let’s “Hook” up
React – Let’s “Hook” upReact – Let’s “Hook” up
React – Let’s “Hook” up
 
Razorpay Payment Gateway Integration In iOS Swift
Razorpay Payment Gateway Integration In iOS SwiftRazorpay Payment Gateway Integration In iOS Swift
Razorpay Payment Gateway Integration In iOS Swift
 
Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swift
 
Line Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-BootLine Messaging API Integration with Spring-Boot
Line Messaging API Integration with Spring-Boot
 
Basic fundamental of ReactJS
Basic fundamental of ReactJSBasic fundamental of ReactJS
Basic fundamental of ReactJS
 
Basic Fundamental of Redux
Basic Fundamental of ReduxBasic Fundamental of Redux
Basic Fundamental of Redux
 
Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )Integration of Highcharts with React ( JavaScript library )
Integration of Highcharts with React ( JavaScript library )
 
Serialization & De-serialization in Java
Serialization & De-serialization in JavaSerialization & De-serialization in Java
Serialization & De-serialization in Java
 
Concept of Stream API Java 1.8
Concept of Stream API Java 1.8Concept of Stream API Java 1.8
Concept of Stream API Java 1.8
 
How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?How to Make Each Round of Testing Count?
How to Make Each Round of Testing Count?
 
Model View Presenter For Android
Model View Presenter For AndroidModel View Presenter For Android
Model View Presenter For Android
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Dropbox Integration in iOS InnovationM

  • 1. | Build a Mobile Experience www.innovationm.com Dropbox Integration in iOS Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com
  • 2. | Build a Mobile Experience www.innovationm.com Dropbox Integration in iOS In this tutorial we will learn- how to integrate Dropbox with iOS applications. Let us take an example of iOS application. We will be talking about the following: 1. Uploading the files from iOS App to Dropbox 2. Downloading files from Dropbox 3. Browsing the Folder / Files structure of Dropbox. There are mainly two types of APIs for Dropbox integration.  Core API – For Uploading, downloading and browsing the file system  Sync API – When there are some changes done in the files / folder then it will help in syncing-up to other devices. Core API Registering the application on Dropbox and linking in the App 1. Register Application with DropBox - To register your application with Dropbox, you need to go on Dropbox App Console and follow these steps.  Select “Create App” on App Console.  Select type of app and type of data which we want to save on dropbox.  Give a unique name to your Application.  Now your app created. It will give you “App key” and “AppSecret key”. 2. Linking iOS App with Dropbox - Download Dropbox SDK and add it your iOS Application. In info.plist URI scheme there is need of adding an item “db-APP_KEY”. In place of “APP KEY” we will put the App key which we get in first step. First you have to create the DBSession object for your app: Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com
  • 3. | Build a Mobile Experience www.innovationm.com #import <DropboxSDK/DropboxSDK.h> DBSession* dbSession = [[[DBSession alloc] initWithAppKey:@"APP_KEY" // add here app key appSecret:@"APP_SECRET" // add here app secret key root:ACCESS_TYPE] // either kDBRootAppFolder or kDBRootDropbox autorelease]; [DBSession setSharedSession:dbSession]; Somewhere in your app add an event to launch the authentication process: - (void)didPressLink { if(![[DBSession sharedSession] isLinked]) { [[DBSession sharedSession] link]; } } Now, we need to add the following code to our application delegate in order to complete the authentication process. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL*)url { if([[DBSession sharedSession] handleOpenURL:url]) { if([[DBSession sharedSession] isLinked]) { NSLog(@"App linked successfully!"); // At this point you can start making API calls } return YES; } // Add whatever other url handling code your app requires here return NO; } Browse Folder and Files of Dropbox All methods on DBRestClient are asynchronous, meaning they don’t immediately return the data they are meant to load. Each method has at least two corresponding DBRestClientDelegate methods, that get called when a request either succeeds or fails. We can list contents of folder by making the following call [[self restClient] loadMetadata:@"/"]; Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com
  • 4. | Build a Mobile Experience www.innovationm.com The REST client will then call your delegate with one of the following call backs: - (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata { if(metadata.isDirectory) { NSLog(@"Folder '%@' contains:", metadata.path); for(DBMetadata *file in metadata.contents) { NSLog(@"t%@", file.filename); } } } - (void)restClient:(DBRestClient *)client loadMetadataFailedWithError:(NSError*)error { NSLog(@"Error loading metadata: %@", error); } Downloading file from Dropbox Now that we know what files are available it’s time to download one. [[self restClient] loadFile:dropboxPath intoPath:localPath] To find out if the file download succeeds or fails you need to implement the following DBRestClientDelegatemethods: - (void)restClient:(DBRestClient*)client loadedFile:(NSString*)localPath { NSLog(@"File loaded into path: %@", localPath); } - (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error { NSLog(@"There was an error loading the file - %@", error); } Uploading file to Dropbox After Downloading we can do with it whatever we want. Now next chalenge is how we can upload a new file on dropbox to share it with other devices & people. Uploading is as simple as downloading: Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com
  • 5. | Build a Mobile Experience www.innovationm.com NSString *localPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]; NSString *filename = @"Info.plist"; NSString *destDir = @"/"; [[self restClient] uploadFile:filename toPath:destDir withParentRev:nil fromPath:localPath]; To see all the operations that are available and the corresponding callback methods look at the DBRestClient.h file in the SDK. Here are the delegate methods that you should implement to get the results of the upload call: -(void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(NSString*)srcPath metadata:(DBMetadata*)metadata { NSLog(@"File uploaded successfully to path: %@", metadata.path); } - (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error { NSLog(@"File upload failed with error - %@", error); } Sync API The Sync API takes care of syncing all your data with Dropbox through a familiar, file system-like interface. It’s like giving your app its own, private Dropbox client. Here we can proceed with the same steps of linking account as in case of core API. Once app is linked we can create a file system object. Syncing of account mainly needs when any change in Dropbox data need to update in all linking devices & people. So we have to implement the “Change Observer” in the program. Observing Changes - A DBFile object is created and is associated with a specific version of that file. You can check whether it is cached and can be read immediately by using the status property. If it is not cached, the -readString: call will wait while it Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com
  • 6. | Build a Mobile Experience www.innovationm.com downloads. If you don’t want to wait, you can use an observer to track its download progress. DBFileStatus *status = file.status; if (!status.cached) { [self.file addObserver:self block:^() { // Check file.status and read if it's ready }]; // Check if the status.cached is now YES to ensure nothing // was missed while adding the observer } You can also check if the version you have is the most recent version of the file with its newerStatus property. If the file is the latest version, this will be nil. If not, it will return the sync status for the newest version of the file. When a file is open, the Sync API will automatically download newer versions of the file as they are available and newerStatus will include the download progress. Once a newer version is downloaded, newerStatus.cached will be set. Then you can call -[DBFile update:] to update the open file to the newest version. In addition to a single file, you can also listen to changes to all files in a folder by using the [DBFilesystem addObserver:forPathAndChildren:] method. Corporate Office: InnovationM Mobile Technologies E-3 (Ground Floor), Sector-3, Noida 201301 (India) t: +91 8447 227337 | e: info@innovationm.com