A library for adding custom UIActions (iOS 6+ share actions) to all apps. Requires a jailbroken iOS.
Add the following repo to your Cydia sources: http://jridgewell.github.io/ActivityLoader/cydia/
Search for ActivityLoader, and install!
Implementing this library will allow you to add any UIActivity to any app that uses UIActivityViewController. That's all the stock Apple apps, right off the bat! I've implemented Instapaper as an example (using @marianoabdala's ZYInstapaperActivity).
- Download the lib and .h files.
- Create a subclass of UIActivity that implements the protocol.
- Do whatever you want.
MyActivity.h
#import <UIKit/UIKit.h>
#import <ActivityLoader/ActivityLoader.h>
@interface MyActivity : UIActivity <ALActivity>
@property (strong, atomic) NSArray *activityItems;
// Required by <ALActivity>
+ (instancetype)instance;
+ (void)load;
// Required by UIActivity
- (NSString *)activityType;
- (NSString *)activityTitle;
- (UIImage *)activityImage;
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems;
- (void)prepareWithActivityItems:(NSArray *)activityItems;
// Implement ONE AND ONLY ONE of the following.
// - (UIViewController *)activityViewController;
- (void)performActivity;
@end
MyActivity.m
#import "MyActivity.h"
@implementation MyActivity
#pragma mark - MyActivity <ALActivity>
+ (instancetype)instance {
static dispatch_once_t pred = 0;
__strong static id _instance = nil;
dispatch_once(&pred, ^{
_instance = [self alloc];
_instance = [_instance init];
});
return _instance;
}
+ (void)load {
id instance = [MyActivity instance];
[[ALActivityLoader sharedInstance] registerActivity:instance
identifier:[instance activityType]
title:[instance activityTitle]];
}
#pragma mark - MyActivity : UIActivity
- (NSString *)activityTitle {
return NSLocalizedString(@"My Super Cool Share Activity", @"");
}
- (NSString *)activityType {
return @"com.example.myactivity";
}
- (UIImage *)activityImage {
return [UIImage imageNamed:@"icon"];
}
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
return YES;
}
- (void)prepareWithActivityItems:(NSArray *)items {
self.activityItems = items;
}
- (void)performActivity {
for (id activityItem in self.activityItems) {
NSLog(@"%@", activityItem);
}
}
@end
Create an example project.- Create:
Theos template- iOSOpenDev template
- More activities!