Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom activities #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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.
@@ -54,6 +70,7 @@ - (NSArray*)excludedActivitiesForKeys:(NSArray*)passedKeys {
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