From 7468a6c9033ffe8cc2315a3de3a759b8745fe43d Mon Sep 17 00:00:00 2001 From: Victor Fernandez Date: Mon, 28 Oct 2019 16:22:31 -0700 Subject: [PATCH] Fix Share dialog not resolving promise when dismissed on iOS (#26842) Summary: On iOS the promised returned by `Share.share(content, options)` isn't resolved if the user dismisses the dialog by either pressing "Cancel" or pressing outside the shared dialog. This PR fixes this issue. This fixes https://github.com/facebook/react-native/issues/26809. ## Changelog [iOS] [Fixed] - Fix promised returned by `Share.share(content, options)` not resolving if share dialog dismissed Pull Request resolved: https://github.com/facebook/react-native/pull/26842 Test Plan: 1. on iOS, open a share dialog with: ```typescript const onShare = async () => { const result = await Share.share({ message: 'example message' }); } ``` 2. Dismiss the opened share dialog and the returned promised should resolve. Differential Revision: D18189755 Pulled By: cpojer fbshipit-source-id: 1269932e9549026afefdaa8478ff7d33bbaeb86f --- React/CoreModules/RCTActionSheetManager.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/CoreModules/RCTActionSheetManager.mm b/React/CoreModules/RCTActionSheetManager.mm index c73aae982e57bd..ca8713692973ad 100644 --- a/React/CoreModules/RCTActionSheetManager.mm +++ b/React/CoreModules/RCTActionSheetManager.mm @@ -183,7 +183,7 @@ - (void)presentViewController:(UIViewController *)alertController shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) { if (activityError) { failureCallback(@[RCTJSErrorFromNSError(activityError)]); - } else if (completed) { + } else if (completed || activityType == nil) { successCallback(@[@(completed), RCTNullIfNil(activityType)]); } };