Skip to content

An iOS 6 UIActivity subclass implementing uploads to Dropbox

License

Notifications You must be signed in to change notification settings

rajdn/GSDropboxActivity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GSDropboxActivity

An iOS 6 UIActivity subclass for uploading to Dropbox.

This is currently work in progress. All suggestions gratefully received!

Usage instructions

1. Install the Dropbox iOS SDK

Download the latest Dropbox iOS SDK and follow Dropbox's instructions for incorporating it into your app.

GSDropboxArchive assumes you have configured the shared DBSession object appropriately. If you follow Dropbox's integration instructions you will have done this. In essence, you just need to make sure you include this in your application delegate's application:didFinishLaunchingWithOptions: method:

#import <DropboxSDK/DropboxSDK.h>

...

DBSession* dbSession = [[DBSession alloc] initWithAppKey:@"APP_KEY"
                                               appSecret:@"APP_SECRET"
                                                    root:ACCESS_TYPE]; // either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];

2. Add GSDropboxActivity to your project

Just copy the GSDropboxActivity folder into your project.

3. Add a GSDropboxActivity object to your list of custom activities

- (void)handleShareButton:(id)sender
{
    NSArray *itemsToShare = @[
        // Your items to share go here.
        // GSDropboxActivity can share NSURL objects where each object is
        // the file URL to a file on disk.
    ];
    NSArray *applicationActivities = @[
        [[GSDropboxActivity alloc] init]
    ];
    UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare
                                                                     applicationActivities:applicationActivities];

    // Present modally - suitable for iPhone.
    // On iPad, you should present in a UIPopoverController
    [self presentViewController:vc animated:YES completion:NULL];
}

4. Listen out for notifications

The following notifications are declared in GSDropboxUploader.h:

GSDropboxUploaderDidStartUploadingFileNotification

Fired when a file starts uploading.

userInfo dictionary entries:

  • GSDropboxUploaderFileURLKey: the URL of the file being uploaded

GSDropboxUploaderDidFinishUploadingFileNotification

Fired when a file finishes uploading.

userInfo dictionary entries:

  • GSDropboxUploaderFileURLKey: the URL of the file being uploaded

GSDropboxUploaderDidGetProgressUpdateNotification

Fired when a file finishes uploading.

userInfo dictionary entries:

  • GSDropboxUploaderFileURLKey: the URL of the file being uploaded
  • GSDropboxUploaderProgressKey: the current upload progress; an NSNumber whose floatValue is between 0.0 and 1.0

GSDropboxUploaderDidFailNotification

Fired when a file fails to upload.

userInfo dictionary entries:

  • GSDropboxUploaderFileURLKey: the URL of the file being uploaded

License

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License.

You're free to use this code in any project, including commercial. Please include the following text somewhere suitable, e.g. your app's About screen:

Uses GSDropboxArchive by Simon Whitaker

About

An iOS 6 UIActivity subclass implementing uploads to Dropbox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published