Skip to content

Support custom activities#32

Open
grabbou wants to merge 1 commit intonaoufal:masterfrom
grabbou:patch-2
Open

Support custom activities#32
grabbou wants to merge 1 commit intonaoufal:masterfrom
grabbou:patch-2

Conversation

@grabbou
Copy link
Contributor

@grabbou grabbou commented Feb 4, 2016

This pull request adds ability to include custom app specific activities that subclass UIActivity.

To use it, subclass UIActivity (make custom one) and make it react module, example code:

// InstagramActivity.h
#import "RCTBridgeModule.h"
#import <UIKit/UIActivity.h>

@interface InstagramActivity : UIActivity <RCTBridgeModule>

@end
// InstagramActivity.m
#import "InstagramActivity.h"
@import UIKit;

@implementation InstagramActivity

@synthesize bridge = _bridge;

RCT_EXPORT_MODULE(InstagramActivity)

- (NSString *)activityType
{
    return @"com.grabbou.whatever";
}

- (NSString *)activityTitle {
    return @"Custom App";
}

- (UIImage *)activityImage {
    return [UIImage imageNamed:@"Logo"];
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
    return YES;
}

- (void)prepareWithActivityItems:(NSArray *)activityItems {
}

- (UIViewController *)activityViewController {
    return nil;
}

- (void)performActivity {
    [self activityDidFinish:YES];
}

@end

And just call:

ActivityView.show({
   customActivities: ['InstagramActivity']
});

which more or less produces the below result:

screen shot 2016-02-04 at 11 21 00


@naoufal EDIT: Closes #28

This pull request adds ability to include custom app specific activities that subclass UIActivity.
NSURL *url = args[@"url"];
NSString *imageUrl = args[@"imageUrl"];
NSArray *activitiesToExclude = args[@"exclude"];
NSArray *customActivitiesToAdd = args[@"customActivities"];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to customActivitiesToInclude.

@naoufal
Copy link
Owner

naoufal commented Feb 4, 2016

@grabbou Could you update the README to reflect your changes?

@naoufal
Copy link
Owner

naoufal commented Feb 4, 2016

Aside from the couple comments, LGTM 👍

@naoufal naoufal self-assigned this Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants