diff --git a/ActivityMailItemSource.h b/ActivityMailItemSource.h new file mode 100644 index 0000000..72d01c8 --- /dev/null +++ b/ActivityMailItemSource.h @@ -0,0 +1,10 @@ + +#import +#import + +@interface ActivityMailItemSource : NSObject ++(instancetype)itemSourceWithText:(NSString*)text; + +-(instancetype)initWithText:(NSString*)text; + +@end diff --git a/ActivityMailItemSource.m b/ActivityMailItemSource.m new file mode 100644 index 0000000..19dbfb8 --- /dev/null +++ b/ActivityMailItemSource.m @@ -0,0 +1,37 @@ +#import "ActivityMailItemSource.h" + +@interface ActivityMailItemSource() +@property (nonatomic) NSString* text; +@end + +@implementation ActivityMailItemSource + ++(instancetype)itemSourceWithText:(NSString*)text{ + return [[ActivityMailItemSource alloc] initWithText:text]; +} + + +-(instancetype)initWithText:(NSString*)text{ + self = [super init]; + if(self){ + self.text = text; + } + return self; +} + +#pragma mark - UIActivityItemSource protocol +- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController{ + return @""; +} + +- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType{ + return self.text; +} + +- (NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType{ + if([UIActivityTypeMail isEqualToString:activityType]) + return self.text; + return nil; +} + +@end diff --git a/ActivityView.m b/ActivityView.m index b5e03a4..ef76fc2 100644 --- a/ActivityView.m +++ b/ActivityView.m @@ -3,6 +3,7 @@ #import "RCTBridge.h" #import "RCTUIManager.h" #import "RCTImageLoader.h" +#import "ActivityMailItemSource.h" @implementation ActivityView @@ -110,7 +111,7 @@ - (void) showWithOptions:(NSDictionary *)args image:(UIImage *)image } if (text) { - [shareObject addObject:text]; + [shareObject addObject:[ActivityMailItemSource itemSourceWithText:text]]; } if (url) { diff --git a/ActivityView.xcodeproj/project.pbxproj b/ActivityView.xcodeproj/project.pbxproj index 6eab57d..9e7b13c 100644 --- a/ActivityView.xcodeproj/project.pbxproj +++ b/ActivityView.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 13BE3DEE1AC21097009241FE /* ActivityView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* ActivityView.m */; }; + DF3E79531C9BFBEA0054A8C8 /* ActivityMailItemSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DF3E79521C9BFBEA0054A8C8 /* ActivityMailItemSource.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -26,6 +27,8 @@ 134814201AA4EA6300B7C361 /* libActivityView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libActivityView.a; sourceTree = BUILT_PRODUCTS_DIR; }; 13BE3DEC1AC21097009241FE /* ActivityView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityView.h; sourceTree = ""; }; 13BE3DED1AC21097009241FE /* ActivityView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActivityView.m; sourceTree = ""; }; + DF3E79511C9BFBEA0054A8C8 /* ActivityMailItemSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityMailItemSource.h; sourceTree = ""; }; + DF3E79521C9BFBEA0054A8C8 /* ActivityMailItemSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActivityMailItemSource.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -52,6 +55,8 @@ children = ( 13BE3DEC1AC21097009241FE /* ActivityView.h */, 13BE3DED1AC21097009241FE /* ActivityView.m */, + DF3E79511C9BFBEA0054A8C8 /* ActivityMailItemSource.h */, + DF3E79521C9BFBEA0054A8C8 /* ActivityMailItemSource.m */, 134814211AA4EA7D00B7C361 /* Products */, ); sourceTree = ""; @@ -112,6 +117,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DF3E79531C9BFBEA0054A8C8 /* ActivityMailItemSource.m in Sources */, 13BE3DEE1AC21097009241FE /* ActivityView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0;