Skip to content

Commit

Permalink
Only delete files when the sharing is completed successfully or the s…
Browse files Browse the repository at this point in the history
…haring sheet being completely cancelled
  • Loading branch information
julien.fougere committed Jul 10, 2020
1 parent 4d7511d commit e5b9e8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ios/SocialSharing.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ - (void)shareInternal:(CDVInvokedUrlCommand*)command withOptions:(NSDictionary*)

if ([activityVC respondsToSelector:(@selector(setCompletionWithItemsHandler:))]) {
[activityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray * returnedItems, NSError * activityError) {
[self cleanupStoredFiles];
if (completed == YES || activityType == nil) {
[self cleanupStoredFiles];
}
if (boolResponse) {
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:completed]
callbackId:command.callbackId];
Expand All @@ -148,7 +150,9 @@ - (void)shareInternal:(CDVInvokedUrlCommand*)command withOptions:(NSDictionary*)
// let's suppress this warning otherwise folks will start opening issues while it's not relevant
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
[self cleanupStoredFiles];
if (completed == YES || activityType == nil) {
[self cleanupStoredFiles];
}
NSDictionary * result = @{@"completed":@(completed), @"app":activityType == nil ? @"" : activityType};
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
Expand Down

0 comments on commit e5b9e8b

Please sign in to comment.