Latest 1.0.5
Homepage https://github.com/zlib/ObjectiveDropbox
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit, WebKit
Authors

Version
License
Platform

The most complete third-party Objective-C SDK for integrating with the Dropbox API v2.

What is it capable of?

Everything what Dropbox HTTP API v2 is capable of (except Dropbox Business API).

Requirements

  • Xcode 7+
  • iOS 8+ (CocoaPods or manual installation)
  • iOS 7+ (manual installation only)

Installation

ObjectiveDropbox is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ObjectiveDropbox"

Or you can install it manually by copying source files into your project. In this case you should add WebKit.framework with ‘Optional’ status to your target.

Example project

To run the example project, clone the repo, and run ‘ObjectiveDropbox.xcworkspace’ from the Example directory.

Usage

Use the following import:

#import "DropboxClient.h"

Then create DropboxClient:

DropboxClient *dropboxClient = [[DropboxClient alloc] initWithAppKey:<DropboxApp key> 
                                redirectURL:<redirectURL> restartAllTasksAfterRelaunch:YES];

I recommend to use ‘http://localhost‘ as redirectURL (don’t forget to add it in your Dropbox App page).

If you want to use multiple Dropbox accounts simultaneously create each DropboxClient with this initializer:

DropboxClient *dropboxClient = [[DropboxClient alloc] initWithAppKey:<DropboxApp key> 
                                redirectURL:<redirectURL> 
                                restartAllTasksAfterRelaunch:YES 
                                keychainAccount:<account string>];

Get access token before the first request:
(user will see Dropbox authentication UI on this step)

[dropboxClient getNewTokenWithSuccess:^ { ... } fail:^(NSString * _Nonnull errorSummary) { ... }];

Access token will be saved to user’s keychain and restored later. You don’t have to call that method if your dropboxClient.accessToken != nil.

If you want to change Dropbox user, use this code:

dropboxClient.accessToken = nil;

And then call [dropboxClient getNewTokenWithSuccess:fail:] again.

Use all Dropbox features like this:

DropboxCommitInfo *commitInfo = [[DropboxCommitInfo alloc] initWithPath:@"/myfile.txt" 
                                mode:[[DropboxWriteMode alloc] initWithOverwrite]];
[dropboxClient.files upload:commitInfo sourceFileUrl:sourceFileURL 
progress:^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
    NSLog(@"Upload progress %i%%", (int)(100.0 * totalBytesSent/totalBytesExpectedToSend));
} success:^(DropboxFileMetadata * _Nonnull uploadResult) {
    NSLog(@"File uploaded: %@", uploadResult);
} fail:^(DropboxError * _Nonnull error) {
    NSLog(@"Upload failed with error: %@", error);
}];

See DropboxClient.h for all available methods.

Each download/upload method returns a task object. You can cancel, suspend and resume it. Your download/upload tasks will remain active in background (background fetch must be ON in your target’s entitlements).

If you want to be a good iOS citizen add these lines to your AppDelegate implementation:

- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler
{
    NSDictionary *userInfo = @{@"sessionIdentifier": identifier, @"completionHandler": completionHandler};
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ObjectiveDropboxBackgroundSessionUpdated" object:nil userInfo:userInfo];
}

Author

Mikhail Motyzhenkov, [email protected]

License

ObjectiveDropbox is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ObjectiveDropbox",
    "version": "1.0.5",
    "summary": "Unofficial Objective-C SDK for Dropbox HTTP API v2",
    "description": "ObjectiveDrobpoox contains all necessary classes for working with Dropbox using Objectve-C on iOS.nCocoapods installation supports iOS 8.0 and above. If you need iOS 7 support, copy all ObjectiveDrobpox files to your project and add WebKit as optional framework.",
    "homepage": "https://github.com/zlib/ObjectiveDropbox",
    "license": "MIT",
    "authors": {
        "Mikhail Motyzhenkov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zlib/ObjectiveDropbox.git",
        "tag": "1.0.5"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {},
    "public_header_files": "Pod/Classes/**/*.h",
    "frameworks": [
        "UIKit",
        "WebKit"
    ]
}

Pin It on Pinterest

Share This