Facebook compose sheet view like in iOS 6 for iOS 4 and above
Categories: iOS, iPad, iPhone on Sep.11, 2012

Project based on
Facebook connection with Facebook SDK 3.0.x (last at 2 september 2012)
What is it?
DEFacebookComposeViewController is an iOS 4 compatible composer view for posting picture and message on user wall.
Looks like the Facebook Sheet in iOS 6.
How to use:
1. download and setup Facebook sdk
2. register your app on
3. replace appID in plist file. FacebookAppID and in CFBundleURLTypes

4. #import “DEFacebookComposeViewController.h”
5. use this code for posting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | DEFacebookComposeViewControllerCompletionHandler completionHandler = ^(DEFacebookComposeViewControllerResult result) { switch (result) { case DEFacebookComposeViewControllerResultCancelled: NSLog(@"Facebook Result: Cancelled"); break; case DEFacebookComposeViewControllerResultDone: NSLog(@"Facebook Result: Sent"); break; } [self dismissModalViewControllerAnimated:YES]; }; DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init]; self.modalPresentationStyle = UIModalPresentationCurrentContext; [facebookViewComposer setInitialText:@"Look on this"]; [facebookViewComposer addImage:[UIImage imageNamed:@"1.jpg"]]; facebookViewComposer.completionHandler = completionHandler; [self presentViewController:facebookViewComposer animated:YES completion:^{ }]; |
Similar posts:

September 17th, 2012 on 6:46 pm
Thank you for making this plugin. It’s awesome!
I will use it in my next project.
September 17th, 2012 on 9:28 pm
Hello,
Is it possible to Share a link with it?
Thanks,
Stefan
September 17th, 2012 on 11:17 pm
@Stefan In this solution no, but you can change share parameters for it.
graphPath to @”me/links”
and with parameters: link, picture, description
more info about parameters http://developers.facebook.com/docs/reference/api/link/
September 17th, 2012 on 11:33 pm
:-)
September 21st, 2012 on 5:07 pm
Hi and thanks for great work
I become an error by post the to the Facebook
0x39d045b0: ldr r3, [r4, #8] Thread 1: EXC_BAD_ACCESS (code=!, address=0xb)
And then the app crash
Pleas help me , thanks a lot;-)
October 1st, 2012 on 11:22 am
@muckel_buckel if you still have a problem, please add issue on github and add more fully crash log
October 3rd, 2012 on 7:40 am
I’m not able to integrate your code in my application, based on iOS 5 using Xcode 4.2.
With Facebook SDK 3.1: Shows Linker Error for Unavailable Frameworks for FacebookSDK for Xcode 4.2
With Facebook SDK 3.0: Shows Errors in “DBFacebookComposeViewController.m”
Does your code not compatible with Xcode 4.2 / iOS 5 ?
Please give me advice for this issue.
Thanks
October 3rd, 2012 on 8:56 am
@khaing
You need download facebook sdk, setup and copy framework to project folder
October 3rd, 2012 on 9:21 am
Thanks for reply Sakrist,
I did the same for Facebook SDK.
I even tried both versions as I mentioned, SDK 3.1 & SDK 3.0.8. Both are not working.
October 16th, 2012 on 1:47 pm
To share link u can add this line of code
[facebookViewComposer addURL:url];
October 19th, 2012 on 6:19 pm
@khaing
Check that the frameworks: AdSupport, Social and Account are set as ‘Optional’ in the “Link Binary With Libraries”.
Also be shure to add your app id to the plist file
November 1st, 2012 on 11:40 am
presentViewController: animated: completion: is available from iOS 5.0.
So you do not support iOS 4.x
November 1st, 2012 on 1:21 pm
You can use another presentViewController method
November 8th, 2012 on 3:58 am
Could you maybe tell me how you have the facebook side of things setup – I’ve looked and looked and looked and my project is set up exactly like your example project – i actually affirm on facebook that my app is allowed, and i am transferred back to the app….But I am not getting any errors
However
[FBSession.activeSession isOpen] is returning NO every single time no matter what.
Any ideas?
November 8th, 2012 on 4:21 am
Actually, just figured it out myself. Didn’t realize that code had to go in the app delegate. Might not hurt to say that when talking about the implementation details.
November 23rd, 2012 on 1:02 pm
Hi,
Thanks for this awesome plugin !
I have an issue with the background. I’m not using storyboard and the background is not transparent. Do you have any ideas why ?
I tried to “transform” your project by removing the storyboard (adding UIWindow …) and the background “lost” its transparency too.
Thanks !
November 26th, 2012 on 6:10 pm
I keep getting this error when i post with iOS5.1
“Cannot obtain token/secret from URL: fbxxxxxxxxxx: //authorize/#access_token=”
November 28th, 2012 on 1:49 pm
thank you so much. Cant be easier to integrate!!
December 19th, 2012 on 8:03 am
Kickass class! Thank you for making this the easiest FB implementation going for IOS 5.
Thanks for sharing!
December 20th, 2012 on 8:09 am
Thank you … after the composeView displays, the login and cancel button not performing any action?.. please Guide me.
January 6th, 2013 on 11:29 am
Fantastic plugin!
I’m having the same issue as Funya. Instead of a transparent background, its displaying a full white color. Any ideas?
January 18th, 2013 on 4:16 pm
I have this error when trying to run (XCode 4.3, iOS5 Simulator, ARC):
Undefined symbols for architecture i386:
“_OBJC_CLASS_$_CAShapeLayer”, referenced from:
objc-class-ref in DEFacebookComposeViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
January 18th, 2013 on 4:22 pm
Solved. You need to add QuartzCore.framework to project.
Thanks for your amazing work.
February 11th, 2013 on 10:13 am
For people who has trouble with background you can try this:
ApplicationDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
February 14th, 2013 on 10:55 am
It dosen’t work in iOS 6.1.
I have used another app using DEFacebookComposeViewController,
But it’s same.
please check it
February 14th, 2013 on 2:14 pm
@tulurira thanks! will check at the end of the day.
February 14th, 2013 on 10:25 pm
@tulurira I checked it, and it works for me.
What’s the issue? Could you please report on github?
February 15th, 2013 on 4:38 am
ok. i wrote it on the github.
February 15th, 2013 on 8:12 am
it works !
I didn’t recognize that is posted the photo in my photo folder..
sorry and thanks for your answer !!
February 15th, 2013 on 11:40 am
Hi SAKrist,
I have try your code with facebook sdk 3.0. I am able to run this project but unable to see on my facebook wall.
Can you just let me know what is the problem?
February 25th, 2013 on 8:55 am
please post tuotrial to use it without storyboard in older versions of ios(ios 4)
March 5th, 2013 on 5:46 pm
Great job!
one question, in ios6+ when share something, it shows on feed:
“shared via iOS”
it does not show “..via APPNAME”
how to correct this?
Thank you
March 6th, 2013 on 8:59 am
how to disable the ARC ?
March 7th, 2013 on 6:48 pm
Hello, i have a question, you are using #import if you want it to work on Ios 4? After all the trouble of creating a virtual machine with lion, finding an xcode 4.2, i sadly realized that i can’t use social framework… If there is a way can you pelase tell me ?
March 7th, 2013 on 11:26 pm
@Alex, easy, you need build with iOS 5.0 and try run on iOS simulator 4.0 or device 4.0
March 8th, 2013 on 9:58 am
I tried, it just won’t work…. i even tried to import the ios 6 sdk from another project… it just doesn’t want to work….
March 8th, 2013 on 10:09 am
The only way to test your demo on iOS4 simulator was to open it with Xcode 4.2 on Lion that has the iOS4 simulator. The problem is that this Xcode does not have IOS6 SDK, hence the project does not recognize the Social and Adsupport frameworks that your demo is using: http://dl.dropbox.com/u/146080740/Screenshots/2.png
Also in order to test it on iOS 4 I had to modify your demo for not using Storyboard.
Can you make an iOS4 compatible demo?
March 8th, 2013 on 11:06 am
@Alex I did, will do commit soon as possible
March 8th, 2013 on 3:59 pm
Thank you very muh.
March 8th, 2013 on 5:35 pm
Ok, thank you. Can you please tell us what version of xcode and os are you using?
Even now we are having trouble with findin the solution to this. W don’t know what to do. Thank you :)
March 8th, 2013 on 6:27 pm
Hello Sakrist,
I’m working with Alex.
What Xcode are you using in order to test the iOS4 compatible build?
I can no test on Xcode 4.6 as it does not have iOS4 simulator anymore.
Do you know any method to install the iOS4 simulator on Xcode 4.6?
Thank you.
March 9th, 2013 on 12:02 pm
#import “UIViewController+MJPopupViewController.h”
#import “PAKFBSecureSession.h”
I can’t run the sample, where are these 2 files? :(
March 10th, 2013 on 4:24 pm
Tested on Mac OS X 10.7.5 with Xcode 4.5
March 11th, 2013 on 11:48 am
@Anonymouse What is it? My project does not has those files.
March 11th, 2013 on 6:56 pm
It is on DEFacebookComposeViewController.m on the latest git version
I ended up using an older version but the background becomes opaque black
March 11th, 2013 on 11:52 pm
@Anonymouse Just checked on repository, it’s not. Maybe it yours experiments, just delete it. :)
March 12th, 2013 on 10:01 pm
Ok I tested as you said on: Mac OS X 10.7.5 with Xcode 4.5
It works! Thank you SakrisT.
March 21st, 2013 on 4:09 am
i tried xcode 4.6 and ios 6
FBComposeView.framework & FBComposeView.bundle into my project.
call presentViewController:facebookViewComposer
but error was given
Unknown class DEFacebookSheetCardView in Interface Builder file.
Unknown class DEFacebookTextView in Interface Builder file.
+[UIDevice de_isIOS5]: unrecognized selector sent to class 0x17f9888
…
how to build FBComposeView.framework problem?
March 21st, 2013 on 11:44 am
self-solving!
Build Settings > Linking > Other Linker Flags add -ObjC.
Thank you. great library
March 22nd, 2013 on 2:03 pm
Hi, SAKrisT! The library works great, but I have one problem: background is black. Do you know something about this?
March 23rd, 2013 on 11:46 am
@George
https://github.com/sakrist/FacebookSample/issues/19
March 25th, 2013 on 2:41 pm
I don’t wan’t a black background. I modified the code from DEFacebookComposeViewController’s viewWillAppear (by adding some code from DETweetComposeViewController), but after rotating from portrait to landscape the navigation bar doesn’t resize properly.
https://dl.dropbox.com/u/101739576/Screenshots/o.png
April 4th, 2013 on 2:16 pm
@Sakrist – So using your library how can I keep the background transparent?
April 30th, 2013 on 1:49 pm
Hello, if I were to post more than one picture what should I do?
Thanks for your work!
May 16th, 2013 on 12:34 am
Hello,
I tried to use your plugin, i think i did everything and i think i didn’t miss any step but the app keep ‘crash’ actually not, but when i tried to log myself on facebook (before posting), right before i can granted access to the facebook app, the app close himself.
i tried the sample from github, same pb
Do i miss something ? where’s the problem :(
Thank you