How to Integrate Dropbox with your iOS APP and Perform CRUD Action

blog

Keval Padia

The Dropbox framework is the third party that is available for file sharing with friends from your phone. Using Dropbox can upload, download and share files using the iOS device.Before you start, you will need a Dropbox account. Create one for free right here with 2GB of storage, if you don’t have already.

In this article, we are going to cover in detail on how to integrate Dropbox with your iOS application and perform Add and Remove files via coding on certain user action. Following are the steps.

#1 Register the application

1) Go to https://www.dropbox.com/developers and start registering your app.

2) The first choice to make is between “Drop-ins app” and “Dropbox API app”. Make your proper choice and start with the detailing. To know the difference between “Drop-ins app” and “Dropbox API app”, you can refer to this link

3) Then depending on your app need to select the specific option from the type of access you need.

4) After completing these two steps, you would receive an App key and an App secret key. These are important! Dropbox no longer allows direct login via username/password combination but uses OAuth to authenticate users. You will need the keys for authentication purpose.

#2 Configure your Xcode project

Now open a new Project or an existing one where you would integrate Dropbox, Download the Dropbox SDK for iOS from here.
Follow these steps:

1) Open your project.

2) Navigate to the SDK and drag the DropboxSDK.framework folder into your project in Xcode. Make sure “Copy items into destination group’s folder” is selected.

3) Ensure that you have the Security. framework added to your project. Click here to see how to add framework to a project

#3 Authentication

  • Add the following header to your AppDelegate File.

Now set DBSessionDelegate and DBNetworkRequestDelegate in your AppDelegate file, and for DropBox, session setting add below code in your

• In your AppDelegate file add below code to check if session is linked or not

Add API_KEY in Info.plist

Now you need to add you dropboxAppKey (db- YOUR_APP_KEY) to your info.plist file as shown below, to register for correct URL scheme.

#4 Login

Now for Login to Dropbox add method. It first checks that user is already logged in or not. And if user is not logged in than it will open Login view.

#5 DBRestClientDelegate methods

Now to fetch data from Dropbox use DBRestClient object and add below function in your class to initialize the DBRestClient object. Set DBRestClientDelegate in your class.

After that call below method to fetch data from Dropbox. While calling this method first time make sure to set loadData = @””;

#6 DBRestClientDelegate handle response

Delegate methods of DBRestClientDelegate’s to handle response of loadMetadata:

#7 DBRestClientDelegate Methods for Add Data

To add files to Dropbox, this just needs to call the below method.

To add files to Dropbox at ROOT path

Delegate Methods to add files

#8 DBRestClientDelegate Methods for Delete Data

To Delete files to Dropbox, this just needs to call the below method.

Delegate Methods to Delete files

Full Source Code

 

Related Post

Swift Code Application Programming Language
24 Aug 2021242 Views

Why Swift Code Application Programming Language is the Best?

Swift may be considered a young platform in the development world. But, it has surely paved its way to becoming the most sought after language...

iPhones and iPads: the leader of Smartphone Industry
16 Feb 2019192 Views

Why iPhones and iPads are Currently Ruling the Smartphone Industry

iPhone is a pioneer in the smartphone industry as it was developed much before the Android devices. First iPhone was launched on June 29, 2007...

Mistakes that Angular JavaScript Developers Commit
16 Feb 2019192 Views

12 Common Mistakes that Angular JavaScript Developers Commit

Developers are continuously reviewing codes, finding an error or a bug and then fixing the bug to develop an optimized application. They aim at...