Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)TweetHighScore
- {
- AppController * myDelegate = (((AppController*) [UIApplication sharedApplication].delegate));
- NSString *currOsVersion = [[UIDevice currentDevice] systemVersion];
- float sysver = [currOsVersion floatValue] ;
- if(sysver >= 6.0f)
- {
- NSString *string = [NSString stringWithFormat:@"Just scored %d in Whack-A-Quack game. Get it %@ ",highScore, kGameLink];
- SLComposeViewController*fvc = [SLComposeViewController
- composeViewControllerForServiceType:SLServiceTypeTwitter];
- [fvc setInitialText:string];
- [fvc addImage:[UIImage imageNamed:@"email.png"]];
- [fvc setCompletionHandler:^(SLComposeViewControllerResult result) {
- [myDelegate.navController dismissModalViewControllerAnimated:YES];
- }];
- [myDelegate.navController presentViewController:fvc animated:YES completion:^{
- }];
- }
- else if(sysver >= 5.0f)
- {
- AppController * app = (((AppController*) [UIApplication sharedApplication].delegate));
- TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
- NSString *string = [NSString stringWithFormat:@"Just scored %d in Temple Run. Get it %@ ",highScore, kGameLink];
- [tweetViewController addImage:[UIImage imageNamed:@"email.png"]];
- // [tweetViewController addURL:[NSURL URLWithString:kGameLink]];
- [tweetViewController setInitialText:string];
- [tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
- dispatch_async(dispatch_get_main_queue(), ^{
- {
- if (result == TWTweetComposeViewControllerResultDone)
- {
- //successful
- //[[NSNotificationCenter defaultCenter] postNotificationName:@"PPTweetSuccessful" object:nil];
- }
- else if(result == TWTweetComposeViewControllerResultCancelled)
- {
- //Cancelled
- }
- }
- [app.navController dismissModalViewControllerAnimated:YES];
- [tweetViewController release];
- });
- }];
- [app.navController presentModalViewController:tweetViewController animated:YES];
- }
- else
- {
- UIAlertView* alert= [[[UIAlertView alloc] initWithTitle:@"Twitter App is not found!" message: @"Ooops! You need to update your iOS version to 5 or higher to share on Twitter"
- delegate: NULL cancelButtonTitle: @"Ok" otherButtonTitles: NULL] autorelease];
- [alert show];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement