I call a share sheet from React Native.
It's seemingly working fine.
But excludeActivityTypes may not work properly after the second time.
What's wrong with my code?
Sorry for my poor English.
@objc(NativeModuleShare)
class NativeModuleShare: NSObject, RCTBridgeModule {
static func moduleName() -> String!{
return "NativeModuleShare";
}
static func requiresMainQueueSetup () -> Bool {
return true;
}
@objc
func ShowShareSheet(_ title:String, message:String, url:String)->Void {
let itemSource = ShareActivityItemSource(shareImage: UIImage(named: "logoBgWhite")!, shareText: message, shareTitle: title, shareUrl: url)
let activityVC = UIActivityViewController(activityItems: [itemSource, itemSource.shareText],
applicationActivities: nil)
let excludeActivityTypes = [
UIActivity.ActivityType.postToTwitter,
UIActivity.ActivityType.postToFacebook
]
activityVC.excludedActivityTypes = excludeActivityTypes;
DispatchQueue.main.async {
(UIApplication.shared.delegate as? AppDelegate)?.window.rootViewController?.present(activityVC, animated: true, completion: nil);
}
}
}