I am currently using SLComposeViewController to post a user's score to twitter or facebook (depending on the button they tap). When they share, they are rewarded with virtual currency. The problem that I'm facing is that it will only tell me whether a user hit Send or Cancel. How can I check if the tweet is actually posted to twitter? This will help combat cases where a user attempts to submit the same tweet twice (which twitter doesn't allow).
This is my code for now:
//Check if user can send tweet
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
//This means the user cancelled without sending the Tweet
case SLComposeViewControllerResultCancelled:
NSLog(@"User Canceled");
break;
//This means the user hit 'Send'
case SLComposeViewControllerResultDone:
NSLog(@"User Tapped Send");
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
//Show alert & reward user here
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"Tweet Sheet has been dismissed.");
}];
});
};
[tweetSheet setInitialText:[NSString stringWithFormat:@"Just scored %ld %@! I challenge anyone to try & beat it! ", (long)scene.score, suffix]];
[tweetSheet addURL:[NSURL URLWithString:@"http://appstore.com/appurlhere"]];
[self presentViewController:tweetSheet animated:YES completion:^{
NSLog(@"Tweet sheet has been presented.");
}];
}
else {
//Something went wrong, aka no network connection
};
How can I check if the tweet was actually posted (Using the Social Framework).