I have an app that currently supports posting to Facebook through the feed dialog using the old Facebook SDK for iOS.
After updating to the Facebook SDK 3.1 for iOS, it seems that I can either:
- use the old style API (
Facebook.h
, instantiate aFacebook
, calldialog:...
) - or use the new style API (
FacebookSDK.h
, use sharedFBSession
, native dialogs)
The different header files collide and seem completely incompatible.
Can I do both? If so, then how?
Try to import
instead of
it will solve the duplicate error..
I think you will get an "duplicate error" if you use both. I know it sucks.
Ive been messing with the duplicate error for days now. Please let me know if you got there.
It's impossible, you should use Graph API https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/ instead of Feed Dialog :(
Just include Facebook.h instead. To do this first, Copy the DeprecatedHeaders folder into your Frameworks project. The DeprecatedHeaders are found under ~/Documents/FacebookSDK/FacebookSDK.frameworks/Versions/A/. When you copy it over do not copy the items into your project, so they stay copied as a reference.
Next, in your code where you have:
Replace with this:
You may get an error, in which case close and reopen the project.
Next you want to declare a Facebook object and set the session or clear it whenever your Session is open or closed.
Take as an example, the sample: https://github.com/fbsamples/ios-3.1-howtos/tree/master/ShareNativeDialogsHowTo that is documented here, https://developers.facebook.com/docs/howtos/share-native-dialogs-ios-sdk/
You could make the following changes to that sample to fallback to the feed dialog instead of falling back to a view controller with a share UI. In ViewController.m you would make these changes after including the Facebook header:
You'll probably have to abstract out a common interface and implement it twice in separate source files (so the compiler never sees Facebook.h and FacebookSDK.h in the same file).