Archive for the Announcements Category

More support for iPhone integration with Box

The iPhone is a powerful platform for creating content, viewing files and communicating with friends and associates. One of the big problems we’ve seen, however, is that it’s difficult to share documents with others from the phone. Many solutions exist but they require large amounts of custom code, building or configuring server components, or using confusing API’s.

We want it to be as easy as possible for developers to build applications that can upload, download and share files from the mobile phone. Today we’re introducing two code libraries that developers can use to incorporate Box.net’s functionality into their iPhone applications.

The first set of code we’re introducing handles all of the basic calls to the Box server including Login, Registration, GetAccountTree, Share and Upload and even parses and returns these calls as Objective-C objects. To access it, go to http://developers.box.net/ApiExamples and download the zip file in the Objective-C folder.

The second set of code we’re introducing is a subclass of UIViewController - BoxPopupController. It provides a user interface that handles all of the tasks of registration/login, folder selection, upload and sharing. The BoxPopupController can be presented as a modal view controller. It saves the user’s account name and authentication token, preferred upload location, and even email addresses with which to share the newly uploaded file. With the BoxPopupController, all it takes to integrate Box into your application is allocation of a view controller and implementation of five simple delegate methods. You provide the data and Box takes care of the rest.

It’s easy to include either one of these sample libraries in your application. The full instructions are included with the code in the zip file, but I’ll give an overview of the process here.

The BoxSampleCode is split up into two logical folders: ‘Models’ and ‘Model Builders.’ Using classes in BoxSampleCode you can get a BoxUserModel containing the authentication token. With the authentication token, you can easily get a BoxFolderModel, which contains all of the contents of a particular folder.

+(BoxFolderModel*) getFolderForId:(NSNumber*)rootId andToken:(NSString*)token andResponsePointer:(BoxFolderDownloadResponseType*)response andBasePathOrNil:(NSIndexPath*)path;

Other useful functions include registration, uploading, and uploading and sharing.

The BoxPopup code is simple to include in your project - first create a button, then in the callback action create a BoxPopupController. Finally, set the delegate and popup the controller:

BoxPopupController * _boxPopupController;

_boxPopupController = [[BoxPopupController alloc] initWithNibName:@"BoxPopupController" bundle:nil];
_boxPopupController.popupDelegate = self;
[self presentModalViewController:_boxPopupController animated:YES];
[_boxPopupController release];

The BoxPopupController delegate needs to implement only five functions to render the BoxPopup. For example, this is how short the BoxPopupControllerDelegate code can be:

-(NSData*)data {
    return [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Simple Text Format" ofType:@"rtf"]];
}
-(NSString*)fileExtension {
    return @"rtf";
}
-(void)popupShouldExit {
    [self dismissModalViewControllerAnimated:YES];
}
-(NSString*)suggestedFileName {
    return @"notes";
}
-(BOOL)shouldAppendTimeAndDate {
    return YES;
}

That’s it. We are always striving to make our developers’ lives easier, and we hope this will make integrating Box into your iPhone applications a breeze.

Post by Michael Smith, Associate Product Manager, and Alex Willen, OpenBox Intern

Promoting Developers through the OpenBox Directory

Working with Mobile Developers: OpenBox Mobile

Getting started with OpenBox Actions

Send files to Box easily with Quick Import

New API Method: Copy

More sample code for the API - Visual Basic

API Update: Optimizing get_account_tree

New API Method: get_account_info

Platform Enhancements in Progress