Issue
I am using react-native-share
to share images from my app to an other app. It is working fine but my own app is appearing in the share sheet. How can I exclude my app so that it does not appear in share the sheet.
i have used excludedActivityTypes:["com.org.myappIdentifier"]
prop as well but it is not working .
Solution
For reference follow this link:
https://pspdfkit.com/blog/2016/hiding-action-share-extensions-in-your-own-apps/
In node_modules/react-native-share/ios/RNShare.mm add this function at top and replace Your share extension target with your target.
#import <UIKit/UIKit.h>
@interface ActionExtensionBlockerItem : NSObject<UIActivityItemSource>
@end
@implementation ActionExtensionBlockerItem
- (NSString *)activityViewController:(UIActivityViewController *)activityViewController dataTypeIdentifierForActivityType:(UIActivityType)activityType {
return @"Your share extension target ";
}
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(UIActivityType)activityType {
// Returning an NSObject here is safest, because otherwise it is possible for the activity item to actually be shared!
return [NSObject new];
}
- (NSString *)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(UIActivityType)activityType {
return @"";
}
- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(UIActivityType)activityType suggestedSize:(CGSize)size {
return nil;
}
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
return @"";
}
@end
and then in open method add these lines of code.
ActionExtensionBlockerItem *blockerItem = [ActionExtensionBlockerItem new];
// Add the blockerItem to your existing array of items
[items addObject:blockerItem];
This will hopefully fix your issue.
Answered By - Muhammad Ahsan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.