1

In my app i'm using SLComposeViewController to send tweets. I'm also calling its method addURL: like this:

[tweetSheet addURL:[NSURL URLWithString:@"http://itunes.com/apps/MyAppName"]];

and it works fine in iOS 6, but in iOS 7 it opens iTunesStore right after being presented on the screen. How do i fix it?

UPDATE:

 if ([SLComposeViewController isAvailableForServiceType:network])
{
    AppController *appController = (AppController *)[[UIApplication sharedApplication] delegate];
    MyNavigationController *navController = appController.navController;

    UIViewController *currentController = [[navController viewControllers] lastObject];

    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:network];
    [tweetSheet setInitialText:text];
    [tweetSheet addImage:[UIImage imageNamed:temp_character]];
    [tweetSheet addURL:[NSURL URLWithString:@"http://itunes.com/apps/MyAppName"]];

    tweetSheet.completionHandler = ^(SLComposeViewControllerResult result){

        [currentController dismissViewControllerAnimated:YES completion:nil];

        if (result == SLComposeViewControllerResultDone)
          [[NSNotificationCenter defaultCenter] postNotificationName:HC_TWEET_SENT_NOTIFICATION object:nil];

    };

    [currentController presentViewController:tweetSheet animated:YES completion:nil];
}
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161

1 Answers1

0

Your custom socialIntegration class has a bug in it. It only returns a SLComposeViewController if Facebook is available on the device. If it isn't, it returns nothing.

However, you don't test for this when you actually call it:

SLComposeViewController * faceSheet=[self.socialIntegration showFacebook:@"text" andImage:nil andLink:@"link" andView:self];
        dispatch_sync(dispatch_get_main_queue(), ^{
            //[self netConnectionTrue:cell Connected:answer];
            //[tempAlertView show];
            [self presentViewController:faceSheet animated:YES completion:NO];

        });

...you're not checking to see if faceSheet is nil. So if there's no Facebook account you call presentViewController with a nil object, which triggers the error you're seeing.

The reason you are seeing this on iOS 7 is your linked FB accounts probably got reset, but it was probably a source of crashes for your users on iOS 6 as well.

Vizllx
  • 9,135
  • 1
  • 41
  • 79