Skip to content

Instantly share code, notes, and snippets.

@avwave
Created November 28, 2013 08:43
Show Gist options
  • Save avwave/7688905 to your computer and use it in GitHub Desktop.
Save avwave/7688905 to your computer and use it in GitHub Desktop.
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet addImage:image];
[tweetSheet setInitialText:[NSString stringWithFormat:@"%@ %@", kSHARETEXT, self.filterName]];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
[Flurry logEvent:@"Share to twitter - cancelled"];
break;
case SLComposeViewControllerResultDone:
[Flurry logEvent:@"Share to twitter - success"];
break;
default:
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[vc dismissViewControllerAnimated:YES completion:^{
}];
});
};
[vc presentViewController:tweetSheet animated:YES completion:^{
}];
} else {
[[[UIAlertView alloc] initWithTitle:@"Sign in with Twitter"
message:@"Sign in with Twitter on your device"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil] show];
[Flurry logEvent:@"Share to twitter - no twitter detected alert"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment