iOS 6 Social framework not going to settings or no alert
Asked Answered
T

1

14

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.

Thier answered 3/1, 2013 at 18:56 Comment(3)
Smells like a bug to me. Doesn't work on device for any SLServiceType, and only works in the simulator for Twitter and Weibo.Exequies
I'm beginning to believe it's a bug, as well. I wonder what's the best course of action? Pop up my own dialog advising folks to set up accounts (since I can't, apparently, send them to settings)?Thier
That's probably the best way to go, and other than that, if you end up not being able to get this working file a bug report with Apple at bugreporter.apple.comExequies
B
28

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];

}
Bueno answered 9/1, 2013 at 14:19 Comment(9)
That sounds counterintuitive, but heck, I'll give it a try, and report back here to confirm. Thanks for the input.Thier
Yep. It worked for me, as well. Weird. I'll add this to my conclusions above.Thier
Does this work perfectly for you both on the simulator and a device, for both Twitter AND Facebook? On the simulator, the settings button doesn't seem to do anything for me when posting to Facebook without an account set up. Twitter works fine though, the settings button directs the user to the settings screen.Ariew
It works for me, and obviously for him too! So I can't see the problem you are having.Bueno
So when you run this on the simulator without a Facebook account set up, and the alert dialog with the settings button pops up, you're able to click on the settings button and be directed to the Facebook settings page? On my simulator it doesn't do that, only does it for Twitter. Is the code you posted above the exact code you're using?Ariew
It works perfect and exaclty the same for me on both facebook and twitter.Bueno
The only problem I have found is if you hit the home button, the no facebook account alert is persistent and I don't know how to dismiss it.Remunerate
Hi guys it is not working in IOS 7.how can i fix this issue in IOS 7Radiothermy
I don't understand why this is the case, does anyone know what happened to the isAvailableForServiceType: method? was it deprecated?Danaedanaher

© 2022 - 2024 — McMap. All rights reserved.