FaceBook IOS SDK - GitHub - ios

I start writing a simple app to use FaceBook IOS SDK from GitHub.
I have a few questions about it:
Is there a better documentation about those Delegate .. functions ? I cannot find those except the ones in DemoApp in the package
In the DemoApp, fbDidLogin, fbDidNotLogin and fbDidLogout are never called ... even a dialog is shown and I typed in username and password for logging in

I finished my application with FaceBook SDK.Therefore, I can answer my own questions now.
1) Developer can follow the DemoApp OR can visit http://thinkdiff.net/facebook/how-to-develop-facebook-application-for-iphone/ for more information
2) fbDidLogin, fbDidNotLogin and fbDidLogout would only be called IF inline Dialog box (for FaceBook) is used. Those delegate functions won't be called IF FaecBook app or Safari browser is used instead

Related

Link to open up iOS app from facebook and twitter page and other ios app?

Hi I have a requirement in my app. From my ios Application(myapp),i share a link to facebook. Then I opened up my facebook account in browser or Facebook application and clicked the link, link should open in myapp if myapp is installed in the device otherwise link should open in browser. How can I achieve this ? Please suggest me step by step. Thanks in advance for your consideration and help.
I am not sure if this is possible. I have looked at various questions including
Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?
as I am sure you might have already done but these questions target their own app, mainly web app, but you want that behavior to occur from an app that is not yours like twitter or facebook. But what you can do is show them two links on facebook/twitter, if they have installed press link 1 and if they want to install, press link 2 and you can pass parameters in link 1 as you might already know.
I will also keep checking answer of this question if some one comes and gives a better solution.
There is an option called custom URL scheme in iOS. It will help you to create a URL scheme which identifies your application. You can post link with this URL scheme and when you tap on this link on your iOS device it will open up your mobile app. Please see the link below to know how to setup this.
Custom URL Scheme in iOS
This is called 'deep URL linking'. Facebook have built a service called 'App Links', which seems pretty cool.
https://developers.facebook.com/docs/ios/app-links

iOS Facebook Like Button Not Working With iOS App

Trying to add the Facebook Like Button to an iOS App. Followed the directions online and am seeing an issue.
Without the Facebook App Installed on Simulator (8.x, 7,x):
When pressing the F Like button, we see a transition to Facebook.com but then quickly returns to the iOS App. It does not go to the proper Facebook Like page where the user can like the URL passed.
In the iOS app, the openURL method is being called and the Facebook
wasHandled = [FBAppCall handleOpenURL: url sourceApplication: sourceApplication];
is being called and it returns YES.
Please note that we are also using the Facebook Login Button that is working fine in this app.
The user has already been authenticated with the Facebook Login Button at this point.
Any hints on this would be appreciated.
We are using Facebook iOS SDK 3.21.1
[Addition]
See this article
http://stackoverflow.com/questions/26529314/android-likeview-error
This is what we are seeing in the the URL Error Message in openURL
The like dialog is only available to developers and testers
Which kinda does not make sense? Regular users should be able to see the like dialog to like the item?
For Facebook Like Buttons on iOS and Android.
After you have integrated the latest SDK and you want to test....
1) You must use a Facebook Account that is either the Developer account for the app (the account that the Facebook ID for the app was created) OR a linked tester Facebook account to the Facebook Developer account.
2) You have to use this account to login with on for the App.
3) When testing a "BETA" banner will be on the target page.
4) If these are not in place, for iOS at least you will get an error message in the URL in the openURL routine in the AppDelegate. For Android you will get a "CANCEL" status in your onActivityResult routine.
The like dialog is only available to developers and testers
Hope this helps.
To fully enable the like button for production, please see Ming Li comments above.

"Login cancelled by player" callback in facebook api for Unity IOS (only if you have facebook app in device)

I am using unity facebook api 4.3.6 for ios. Its working perfectly fine if I don't have #facebookapp in my device. Once I download it and try login, it takes me to #facebookapp and redirect again to my game with callback
FB Login callback : {"is_logged_in":false, "user_id":"", "access_token":""}
Login cancelled by player
This happens only if I have facebook app downloaded! I think its some how cache issue but not sure exactly what is it. Any luck?
I believe this is not connected with Unity.
Here is few reasons I faced
You need to ask read and write permissions separately. Wait until you get read permissions than send request for write permission.
Make sure your app is allowed to login ( if you have FB app installed on your device )
Make sure you have your app bundle identifier added to developer.facebook.com
Here is what helped me fixed that problem with Unity Facebook-Android.
setting the sandbox mode ON:
Go to https://developers.facebook.com/apps
Select the respective app from the drop down.
Go to 'Status & Review' from the table in the left side of the page.
Do you want to make this app and all its live features available to the general public? - Select switch to set YES/NO value.
if the ON/OFF button is disable, please go back to Settings and enter a valid email address.
I understood why when the device is installed a facebook app, my app can't login facebook.
First : software OpenSSL create keyhass wrong. I have downloaded OpenSSL from here : http://code.google.com/p/openssl-for-windows/downloads/list , and it creates keyhash wrong.
I have used other OpenSSL sofware, you can download it here : https://www.dropbox.com/sh/t6tt44dc2nm6vza/6mp1W74GiZ , it is create keshash right.
Second: In class FacebookAndroidUtil.cs , line 62, you add System.Environment.GetEnvironmentVariable("HOMEDRIVE") before System.Environment.GetEnvironmentVariable("HOMEPATH"). Facebook SDK requires a file debug.keystore in : C:\Users\UserName.android\debug.keystore.
If the Unity Editor, Edit Setting Facebook has yet to create android debug hash key. Then use the Eclipse Software, create and run onr any project. Eclipse will generate a debug.keystore. If it is't create in folfer : C:\Users\UserName.android\debug.keystore , then find it, coppy and paste into C:\Users\UserName.android\debug.keystore
Third: publish your app in Facebook, so be sure it is:"This app is public and available to all users".

Where exactly should I put the call to [FBSettings publishInstall:appId]

I'm looking at integrating support for tracking Facebook's new mobile app ads.
I've read the tutorial here:
https://developers.facebook.com/docs/tutorials/mobile-app-ads/
It says:
Include the following code to be executed when your app opens for the first time by user
[FBSettings publishInstall:appId];
So the first question is - where do I put this so that it only invokes the call if the install was driven from Facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
Do I need to manually track whether or not I've called the publishInstall before for this specific user? (The preamble sentence implies this - but the SDK documentation for publishInstall implies otherwise).
And even more confusing is that the SDK FBSettings reference includes shouldAutoPublishInstall which defaults to YES. This would suggest that I don't need to do anything other than have the SDK integrated. So why does the tutorial not mention this as an option?
I assume that the appId is the associated Facebook appId (as opposed to the App Store App ID). This is also not clear from the documentation.
I browsed the sources of facebook iOS SDK, and it seems that guide is wrong.
You are right, that autoPublishInstall is set to YES by default, which means we don't need to invoke [FBSettings publishInstall:appId]; manually. AppId is indeed the facebook app id.
When you invoke openActiveSessionWith.... method, it initializes FBSession with
initWithAppID:permissions:defaultAudience:urlSchemeSuffix:tokenCacheStrategy: which contains in the end [FBSettings autoPublishInstall:self.appID];
+ (void)autoPublishInstall:(NSString *)appID {
if ([FBSettings shouldAutoPublishInstall]) {
dispatch_once(&g_publishInstallOnceToken, ^{
// dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will
// cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem.
[[FBSettings class] performSelector:#selector(publishInstall:) withObject:appID afterDelay:FBPublishDelay];
});
}
}
So technically it should report the install out of the box (if I'm not missing something). I'm going to play with it a little more today to see if it works as expected and update answer with results.
Just put it at -[application:didFinishLaunchingWithOptions].
Not all of the apps want to integrate the Facebook login. They only want the feature "mobile app install ads". For these kind of app, they should invoke +[FBSettings publishInstall:appId] manually. On the other hand, if your app has already integrated facebook login, you can assume that the FB sdk has published the installation.
If we just have to put
[FBSettings publishInstall:appId];
manually in
-[application:didFinishLaunchingWithOptions]
how will I identify which install happened from facebook? I don't want FB to get credit for someone who found my app themselves on the app store.
put the code in Appdelegate DidbecomeActive method
- (void)applicationDidBecomeActive:(UIApplication *)application
hope this help :)

Facebook facebook-ios-sdk and graph api is not working

I am using the official facebook ios sdk in my app (https://github.com/facebook/facebook-ios-sdk)
It was all working fine. I was able to log in, pull all my info from Facebook, post things on my wall. Do all those regular stuff that you do...
But since last night, it appears to be broken. When the login window appears and the user logs in, instead of getting the authkey and getting a callback. The login window directs users to facebook.com.
Did anyone else notice the problem? Is there any fix to it or we just assume that the graph API is broken right now and wait?
I assume Facebook were just having a problem. If you had it working & did not change the code then the issue is elsewhere?
In general it's a pain to get working so the following is a brief hint to anyone who is stuck.
Having spent 2 days getting this working I recommend (assuming you have registered an app with Facebook) :
First get the demo app working.
This ensures you have your app ID and worked out how to add the URL stuff into the plist. This is explained in the docs so should not give you much trouble.
Once all the options in the demo app work (login, post, upload a sample photo) you can think about your own app.
Many things are different but you still need to have the AppDelegate method for the URL stuff. Also this method does not work as is assuming your app is using more than one view controller.
I went for the approach of setting up facebook in the app delegate eg:
Facebook *facebook
and in the actual facebook routine referencing that appDelegate's facebook object eg:
appDelegate.facebook
This approach is the subject of quite a few posts on the interweb so you should be able to google it.
I can log on, get info, post & upload photos.
I'm having the same issue, i downloaded the "official example" from gitHub, and wehn compiled it does she#. After i login, it open safari and redirects to http://www.facebook.com/connect/uiserver.php, and the app stalls. Well that's not the way to do it, Facebook. They are obsoleting the old rest api, meanwhile the "new" graph things not working. Im currently using graph API with my own calls to graph.
Check if you have done the following
1.URL scheme corresponding to your Facebook application ID is set. Your URL Schemes must contain item looking like "fb1234567890"
2.AppDelegate's method must be implemented:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
it is described in https://github.com/facebook/facebook-ios-sdk "Authentication and Authorization".
Read also "Single Sign-On".

Resources