An iOS 6 UIActivity subclass for uploading to Dropbox.
This is currently work in progress. All suggestions gratefully received!
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];
Just copy the GSDropboxActivity folder into your project.
- (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];
}
The following notifications are declared in GSDropboxUploader.h
:
Fired when a file starts uploading.
userInfo dictionary entries:
GSDropboxUploaderFileURLKey
: the URL of the file being uploaded
Fired when a file finishes uploading.
userInfo dictionary entries:
GSDropboxUploaderFileURLKey
: the URL of the file being uploaded
Fired when a file finishes uploading.
userInfo dictionary entries:
GSDropboxUploaderFileURLKey
: the URL of the file being uploadedGSDropboxUploaderProgressKey
: the current upload progress; anNSNumber
whosefloatValue
is between 0.0 and 1.0
Fired when a file fails to upload.
userInfo dictionary entries:
GSDropboxUploaderFileURLKey
: the URL of the file being uploaded
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