Skip to content

Commit

Permalink
#140 cancel triggers success callback
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Apr 7, 2015
1 parent aab6f24 commit efa5fdd
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 @@ -225,8 +225,10 @@ - (void)shareViaInternal:(CDVInvokedUrlCommand*)command
[self.viewController presentViewController:composeViewController animated:YES completion:nil];

[composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
// now check for availability of the app and invoke the correct callback
if ([self isAvailableForSharing:command type:type]) {
if (SLComposeViewControllerResultCancelled == result) {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"cancelled"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else if ([self isAvailableForSharing:command type:type]) {
CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:SLComposeViewControllerResultDone == result];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
Expand All @@ -236,6 +238,8 @@ - (void)shareViaInternal:(CDVInvokedUrlCommand*)command
// required for iOS6 (issues #162 and #167)
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}];

[self.viewController presentViewController:composeViewController animated:YES completion:nil];
}

- (void)shareViaEmail:(CDVInvokedUrlCommand*)command {
Expand Down

0 comments on commit efa5fdd

Please sign in to comment.