Skip to content

Commit a4fbb8e

Browse files
tomtargoszfacebook-github-bot
authored andcommitted
Fix ShareSheet crash on iOS 13 (#26429)
Summary: Currently on iOS 13 the app will crash if you: - Open the share sheet - Tap something like messages or photos - Cancel the dialog - Perform any other action This is because `shareController.completionWithItemsHandler` is called when the dialog box is canceled and currently `failureCallback` or `successCallback` will always be called. In the situation above, `activityError` is `nil` so `successCallback` will be called even though `completed` is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash. This PR adds a check to make sure `completed` is true before calling `successCallback`. This way `successCallback` will only be called when the user has successfully completed an action and the ShareSheet is closed. ## Changelog [iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13 Pull Request resolved: #26429 Test Plan: - Saved an image successfully - Opened and dismissed the `Photos` dialog multiple times without crashing Differential Revision: D17369712 Pulled By: PeteTheHeat fbshipit-source-id: 228b696243cd39fad1fa134f4412d95d845b1bc5
1 parent dbf070c commit a4fbb8e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Libraries/ActionSheetIOS/RCTActionSheetManager.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ - (void)presentViewController:(UIViewController *)alertController
166166
shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) {
167167
if (activityError) {
168168
failureCallback(activityError);
169-
} else {
169+
} else if (completed) {
170170
successCallback(@[@(completed), RCTNullIfNil(activityType)]);
171171
}
172172
};

0 commit comments

Comments
 (0)