Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 6 Social framework not going to settings or no alert

I'm trying to implement the new social framework in iOS6, and have it working, except for 2 weird problems. If I've enabled the services I'm interested in (say... FaceBook), then it works fine. However, if the accounts are deleted from the settings panel (let's say FaceBook, to be consistent), then I get differing, and frustrating behaviors in the simulator and the device.

Here's the relevant code in my view controller:

//Method for FaceBook

- (IBAction)doFacebook:(id)sender{
//check to see if facebook account exists
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

    // Create the view controller defined in the .h file

    fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    // make the default string
    NSString *FBString= [NSString
                         stringWithFormat:@"%@\r via #GibberishGenerator", gibText.text];
    [fb setInitialText:FBString];
    // show the controller
    [self presentViewController:fb animated:YES completion:nil];

    }
}

And here's the weird behavior when firing off the above method:

In the simulator (version 6.0 (358.4) I get the dialog informing me that I haven't set up any faceBook accounts with "Settings" and "Cancel" buttons. Hitting "Settings" just dismisses the dialog, but doesn't take me to the settings panel.

On my iPhone 4s running 6.01, hitting the button that triggers the method results in... nothing. In other words, I get no dialog informing me that I have to set up a FaceBook account.

Thanks in advance for your help.


OK... Here's the fix:

Here's my new implementation, based on user1734802's helpful comment.

//Method for FaceBook

- (IBAction)doFacebook:(id)sender{

    // Create the view controller defined in the .h file

    fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    // make the default string
    NSString *FBString= [NSString
                         stringWithFormat:@"%@\r via #GibberishGenerator", gibText.text];
    [fb setInitialText:FBString];
    // show the controller
    [self presentViewController:fb animated:YES completion:nil];

      }

At some point I expect

 [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])

to actually work correctly (triggering the automatic dialog, and taking you to settings), so I actually just commented it out in my code.

like image 938
james Burns Avatar asked Jan 03 '13 18:01

james Burns


1 Answers

I had the same problem, i fixed it by removing the If statement:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])

Then the view will display although there is no Facebook/Twitter account configured in the settings. And the "No Facebook/Twitter accounts" alertView showed! And I was able to hit the "Settings" button on the alert, and it directed me to the settings (Configure Facebook/Twitter account in the settings)

This is the code I used, and it works perfectly for me:

- (IBAction)bTwitter:(id)sender {

mySLComposerSheet = [[SLComposeViewController alloc] init];

mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

[mySLComposerSheet setInitialText:@""];

[mySLComposerSheet addImage:[UIImage imageNamed:@""]];

[self presentViewController:mySLComposerSheet animated:YES completion:nil];

}
like image 160
Peter Avatar answered Dec 28 '22 14:12

Peter