Launch Facebook messenger Share extension from my iOS app - iphone

I'm developing an iPhone app and I want to launch Facebook messenger share extension from when user wants to send a photo to one of his friends.
How can this be done?
I was able to use FBdialog, but this takes the user our of the app and I don't like this option.
Thanks.

Your application must have received permissions by the user via the access token (publish_actions). Otherwise, you'll get into the fast-app-switch, which displays a separate page.
Once a user gives your app appropriate permissions, then your FB action can be seamless, without switching across.
In a nutshell, you should implement a "login" method that users "login" to your application using Facebook (more specifically - gives your app permissions to access certain parts of their FB profile), and then you should be able to use native SDK capabilities.

If you use UIActivityViewController as long as the shared objects (NSString, UIImage, etc) are compatible it should show up automatically on the share list sheet in iOS 8.
The user may have to enable it by pressing "More"

Related

Share 1 Facebook App ID with multiple iOS Apps using ACAccountStore

I have an iOS app configured to use Facebook login via iOS's ACACcountStore. I'm not using the Facebook SDK.
I'm creating another app (for the same company) and I'm trying to take advantage of the existing Facebook App that I've set up for the first iOS app.
I've read that you can add multiple bundle ids in the Facebook App's Settings. I've done this, but unfortunately, I get an ACErrorPermissionDenied error when trying to log in.
Using iOS's built in Facebook login, am I able to share one Facebook App Id with multiple iOS apps with different bundle ids?
Ahh, figured it out.
The good news is that this is definitely possible. Just go into your Facebook app's settings and add another bundle id.
Make sure that the bundle id you've set in your app is exactly the same as the one you add to facebook.
In my case, I was formatting part of my bundle id like so:
com.myApp.${MY_CUSTOM_BUNDLE_ID_SUFFIX:rfc1034identifier}.
MY_CUSTOM_BUNDLE_ID_SUFFIX is a User-Defined setting in my Target's Build Settings. I had it set to:
foo.bar
When processed with the rfc1034identifier, the . was converted to a - so it ended up being com.myApp.foo-bar, so the mismatch is what was causing login to fail.

Facebook Login in two different apps of one iPhone

I developed two apps with facebook integration in both the Apps , my requirement is if i opend one app and login to facebook account , and if i open second app it should login at the same time .
Thanks
nikhil.
This isn't really possible, since both apps would then have to use the same Facebook App ID.
And since the Facebook App ID is should be part of the App URL scheme, iOS can't see the difference between the two apps and will open the one installed last.
You can try an store the Facebook login data in the keychain and use that in the other app, but not sure if that will work.

App Store can accept this flow or not

I have integrated Facebook functionality into my applications. By using the link https://github.com/facebook/facebook-ios-sdk, I have integrated the Facebook. In this application, at the time of login, it's opening Safari and at the same time the application is going to the background and then after login again it's coming back to the application. My intention is that this flow can accept the application store or not.
This is the official Facebook iOS SDK and many apps in App Store already use it. So you can use it inside your app.
Also, the flow in your question is exactly what the documentation of the library describes and is, again, used by apps that are already in App Store:
If the device is running in a version of iOS that supports multitasking, but it doesn't have the Facebook app of version 3.2.3 or greater installed, the SDK will open the authorization dialog in Safari. After the user grants or revokes the authorization, Safari redirects back to the calling app. Similar to the Facebook app based authorization, this allows multiple apps to share the same Facebook user access_token through the Safari cookie.
So, yes, there is nothing wrong with this flow.

Facebook iOS SDK restarts the application

I want to publish scores of iPad game on Facebook when the game is over, game is made using cocos2d. I have made UIViewController and assigned it as delegate for FBConnect as well. I add it's subview on top of glView when i need to publish scores.But Facebook iOS SDK Single-Sign-On takes the application back to the first view of application when redirects after authorizing facebook app. I want it to simply remove this view from top view instead of going back to from where the application started. Is there any way to resume application from same point instead of restarting?
Also, how can we check if Facebook app is already authorized by a user so that application can skip authorization and can show "publish on wall" dialog start away?
If you are using Facebook lastest SDK's Single-sign on feature than the control gets out of your application. Solution is to leave SSO feature and make your custom class for Facebook connectivity. Implement login, publish and logout where you want and save access authorization in NSUSerDefaults. This post contains detail code to implement it. Hope it helps :)

Facebook iOS SDK - GitHub - Cannot switch back calling app

According to the GitHub,
If the app is running in a version of iOS that supports multitasking, and if the device has the Facebook app of version 3.2.3 or greater installed, the SDK attempts to open the authorization dialog withing the Facebook app. After the user grants or declines the authorization, the Facebook app redirects back to the calling app, passing the authorization token, expiration, and any other parameters the Facebook OAuth server may return.*
My application calls authorize: permissions: delegate: and my application is suspended and Facebook application is launched and authorization is asked. After the user allow or disallow, the Facebook applications stayed on NEWS FEED (not returning to my application).
Questions:
Is it possible to authorize or logged-in and returning to my application?
How can my application check whether the authorization and logged-in is done and no need to re-do again?
I found this.
During single sign-on, the Facebook application isn't redirecting back to my application after a user authorizes it. What's wrong?
Make sure you've edited your application's .plist file properly, so that your applicaition binds to the fb[appId]:// URL scheme (where "[appId]" is your Facebook application ID).
My Application can be switched :)
Thanks all
After struggling for long time finally got a solution for this problem, I dont its correct but its working like charm for my App:
go to developer.facebook.com
Select your app from list (App which app is your are using in URL scheme)
If your app is selected as native app then it will ask for bundle identifiers
provide him bundle identifier by using which you are building your app
if your using wildcard bundle identifier then provide like com.product.abc otherwise provide full bundle identifier.