ARWebServerActivity
A UIActivity subclass that share files via GCDWebServer with Twitter Bootstrap UI.
Install / Use
/learn @alexruperez/ARWebServerActivityREADME
ARWebServerActivity
Overview
ARWebServerActivity is a UIActivity subclass that provides an "Share via web server" action to a UIActivityViewController to share files via swisspol/GCDWebServer with Twitter Bootstrap UI.
You can share:
- NSString as TXT File.
- UIImage as PNG File.
- NSURL to a local/remote file.
- NSData as DATA File.
- NSDictionary as JSON File.
- NSArray as JSON File.

Clone the example proyect
To pull the swisspol/GCDWebServer submodule run:
git clone --recursive git@github.com:alexruperez/ARWebServerActivity.git
Requirements
- As
UIActivityis iOS >= 6 only, so is the subclass. - This project uses ARC. If you want to use it in a non ARC project, you must add the
-fobjc-arccompiler flag to ARWebServerActivity.m and ARWebServerActivityViewController.m in Target Settings > Build Phases > Compile Sources.
Installation
Add the ARWebServerActivity subfolder to your project. There are no required libraries other than swisspol/GCDWebServer and its requirements.
Usage
(See example Xcode project)
Simply alloc/init an instance of ARWebServerActivity and pass that object into the applicationActivities array when creating a UIActivityViewController.
ARWebServerActivity *webServerActivity = [[ARWebServerActivity alloc] init];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Hello World!", [UIImage imageNamed:@"Example"], [NSURL fileURLWithPath:@"file/path"], [NSURL URLWithString:@"file/url"], [@"data" dataUsingEncoding:NSUTF8StringEncoding], @{@"key": @[@"value1", @"value2"]}, @[@"value1", @"value2"]] applicationActivities:@[webServerActivity]];
[self presentViewController:activityViewController animated:YES completion:nil];
Note that you can include the activity in any UIActivityViewController and it will only be shown to the user if there is a valid object in the activity items.
Customization
To customize this control you can use:
- (instancetype)initWithPort:(NSNumber *)port bonjourName:(NSString *)bonjourName path:(NSString *)path activityViewController:(UIViewController *)activityViewController;
port: swisspol/GCDWebServer port.bonjourName: If you want your server be visible at Bonjour.path: If you want to change the local files path shared by your server. Note that will be removed after sharing.activityViewController: If you want to change the default control UI, you can subclassARWebServerActivityViewControllerand not call[super viewWillAppear:animated];, make your own UIViewController or improve myARWebServerActivityViewControllerand make a pull request.
TO-DO (Help needed!)
- Add (programmatically) Auto Layout constraints to
ARWebServerActivityViewControllerand example Xcode project for screen rotation. - Improve
ARWebServerActivityViewControllerUI.
