alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
763 stars 398 forks source link

Best way to override extractDataFromContext on iOS? #110

Closed cigoe closed 6 years ago

cigoe commented 6 years ago

I'm trying to implement some custom logic but am unable to get the sub-classed method called instead of the one in the parent ReactNativeShareExtension class (confirmed via debugger breakpoints). I have a hunch this may be because RCT_REMAP_METHOD is being used to call the method in question. An example of a setup which compiles file but is not working is below.

@interface TestShareExtension : ReactNativeShareExtension
- (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(^)(NSString *value, NSString* contentType, NSException *exception))callback;
@end

...

- (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(^)(NSString *value, NSString* contentType, NSException *exception))callback {
  NSLog(@"TEST");
}

Any input would be greatly appreciated!

cigoe commented 6 years ago

Figured this out by just keeping it simple not overwriting the method. Instead I just included the files in the main xcode application and not linking the react-native-share-extension library on iOS.