I have an iPhone app that allows users to record videos and I’d like them to be able to share those videos on Facebook.
However, unless the user decides to share, I don’t want him/her to be redirected to Facebook. I’ve tried the method provided in the Facebook iOS tutorial, and it requires the user to be redirected to Facebook and authenticate as soon as the app starts up.
That’s unnecessary.
What I’d like to do is have a “Share” button that allows the user to authenticate and then automatically upload a video right afterward using the POST request.
Is this possible? Has anyone achieved a similar effect?
Thanks.
The answer to this question lies in creating a singleton that operates as both the
FBSessionDelegateand theFBRequestDelegate, and allows you to pass one instance ofFacebookaround your program.I called my singleton
FacebookVideoUploader, and in my app delegate I called:That’s it. This keeps the app delegate uncluttered and let’s the singleton handle the delegate methods.
In my implementation file for my view controller that handles the video upload I put:
[[FacebookVideoUploader sharedInstance] postVideoToFacebook];
}
That’s it. All of the delegate and session methods as well as postVideoToFacebook are handled in the
FacebookVideoUploadersingleton.This allows my users to log into my app without being redirected to Facebook and lets them authenticate as soon as they decide they want to share a video.