isAvailableForServiceType always returns true?

2019-04-05 16:26发布

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.

5条回答
Deceive 欺骗
2楼-- · 2019-04-05 16:48

Did you run the that in Simulator?

It seems isAvailableForServiceType always returns 1 in Simulator.

Maybe you can test it in ipad with IOS6.

查看更多
乱世女痞
3楼-- · 2019-04-05 16:49

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.

查看更多
甜甜的少女心
4楼-- · 2019-04-05 16:49

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楼-- · 2019-04-05 16:49

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.

查看更多
三岁会撩人
6楼-- · 2019-04-05 17:02

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.

查看更多
登录 后发表回答