isAvailableForServiceType always returns true?

2019-04-05 16:45发布

问题:

Simple line of code:

NSLog(@"Checking on Facebook: %d -- Checking on Twitter: %d",[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook], [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]);

Problem is that I'm getting 1 for both BOOLs. That's a problem because neither Twitter nor Facebook is setup with an account. This is on the simulator, so wondering if people have experienced this is happening on devices as well?

Documentation says that it should only return true if the service is available and at least one account is setup. But I'm getting true even without accounts setup. I'd like to use the values to hide some social posting buttons so would like this to work.

回答1:

Did you run the that in Simulator?

It seems isAvailableForServiceType always returns 1 in Simulator.

Maybe you can test it in ipad with IOS6.



回答2:

From my experience, I can confirm this is a bug in iOS Simulator 6.0. The isAvailableForServiceType method always returns TRUE for any service type on iOS Simulator.

On actual device running current iOS 6.0 it is working as expected.



回答3:

you can test isAvailableForServiceType: using iOS 7.1 on which it is working with simulator as well.

Here What I checked

NSLog(@"Facebook Enabled : %d",[SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook];

Please check this.



回答4:

I can also confirm that it's broken [i.e., returns True for all three services] in the Simulator (Xcode 4.5.1, iOS 6.0) -- but that it works properly running on a device (iPhone 4S, running iOS 6.0).



回答5:

isAvailableForServiceType returns true always in both iPhone and iPad simulators.

The same piece of code is working fine in the iOS 6 iPhone and iPad.