Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

DON'T PULL YET: Facebook iOS SDK 3.0 bindings #53

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
Contributor

sblom commented Jul 25, 2012

Looks like Facebook has officially released their iOS SDK 3.0. I just finished up all the bindings. Testing is still required.

I don't know when I'll get a chance to port their latest sample app to C# to prove that the bindings work correctly. Anyone else out there want to help with this?

Owner

jstedfast commented Aug 11, 2012

I would probably suggest having it as a second branch until Facebook SDK 3.0 goes final, and then merging it into master.

ytn3rd commented Sep 7, 2012

I may do some testing into this as I am interested in what FB 3.0 has to offer.

ytn3rd commented Sep 11, 2012

Something is funky with this. Could not get FBLoginView to display the login button, unsure what the deal is with it.

Contributor

sblom commented Sep 11, 2012

Entirely possible. I'm primarily using FBSession and FBRequestConnection, so I've got weak coverage on FBLoginView. Can you either post a screenshot or send me one in email? I'd be happy to help troubleshoot this.

Contributor

sblom commented Sep 11, 2012

Or sample code would help, too.

ytn3rd commented Sep 11, 2012

Will upload some sample code to github.

ytn3rd commented Sep 11, 2012

As it turns out, I did not include the FacebookSDKResources.bundle file ("folder") into my MonoTouch project. After doing that things seemed to be going better. Will let you know if I get any other difficulties.

ytn3rd commented Sep 11, 2012

I think now the bindings for FBGraphUser are off.

When attempting to use

//HelloFBLoginViewDelegate.cs
public override void LoginViewFetchedUserInfo(FBLoginView loginView, FBGraphUser user)
{
    Console.WriteLine(user.FirstName);
}

it will crash. The binding looks like this.

[Export ("first_name")]
string FirstName { get; set; }

but I think it should be

[Export ("first_name")]
string FirstName { get { return ObjectForKey(new NSString(@"first_name")).ToString(); }

as the FBGraphUser object (well the FBGraphObject) is just a json object. Not sure if there is a better way to do what I just said above.

This would also make it read-only, as someones name would be when querying.

This line works in the current bindings.

public override void LoginViewFetchedUserInfo(FBLoginView loginView, FBGraphUser user)
{
    Console.WriteLine(user.ObjectForKey(new NSString(@"first_name")).ToString());
}

Bindings were incorrect for FBPlacePickerViewController. "selection" is actually FBGraphPlace not NSArray (as you only pick one place anyway) according to FBPlacePickerViewController.h.

/*!
 @abstract
 The place that is currently selected in the view.  This is nil
 if nothing is selected.
  */
@property (nonatomic, retain, readonly) id<FBGraphPlace> selection;

When I updated this I would get issues when trying to do something like

placePickerController.Selection.ObjectForKey(new NSString("name")).ToString()

as it would tell me that it can not convert a FBGraphObject to a FBGraphPlace. But it should be a FBGraphPlace in the first place...

Another thing which is behaving oddly is the FBRequestConnection class. In the HelloFacebookSample (pushing up example as I write) it does something like this.

FBRequestConnection.StartForPostStatusUpdate(message, delegate(FBRequestConnection connection, NSObject result, NSError error) {
    showAlert(message, result, error);
    buttonPostStatus.Enabled = true;
});

Ignoring those 2 lines I have in the delegate you can see that it has these 3 things passed in. The result attribute is of type NSObject. Looking at FBRequestConnection.h

/*!
 @method

 @abstract
 Simple method to make a graph API post of a status update. The request  
 uses the active session represented by `[FBSession activeSession]`.

 @param message         The message to post.
 @param handler          The handler block to call when the request completes with a success, error, or cancel action.
 */
+ (FBRequestConnection *)startForPostStatusUpdate:(NSString *)message
                                completionHandler:(FBRequestHandler)handler;

And then looking at how FBRequestHandler is defined

/*!
 @typedef FBRequestHandler

 @abstract
 A block that is passed to addRequest to register for a callback with the results of that
 request once the connection completes.

 @discussion
 Pass a block of this type when calling addRequest.  This will be called once
 the request completes.  The call occurs on the UI thread.

 @param connection      The `FBRequestConnection` that sent the request.

 @param result          The result of the request.  This is a translation of
                        JSON data to `NSDictionary` and `NSArray` objects.  This
                        is nil if there was an error.

 @param error           The `NSError` representing any error that occurred.

*/
typedef void (^FBRequestHandler)(FBRequestConnection *connection, 
                                 id result,
                                 NSError *error);

You can see that result is JSON data that is now NSDictionary or NSArray objects.

Going back to my example before that uses this result, it was erroring saying I couldn't cast again. Apparently this result of JSON data is actually now FBGraphObject... I got no idea why these things are all becming FBGraphObjects... all I know is that

FBRequestConnection.StartForPostStatusUpdate(message, delegate(FBRequestConnection connection, NSObject result, NSError error) {
    FBGraphObject resultObj = result as FBGraphObject;
    Console.WriteLine(resultObj.ObjectForKey(new NSString(@"id")).ToString());
});

works...

Also, I am unsure how to post merges via GitHub of changed files as I go through and double check them.

The latests SDK binded is 3.0? Do you have plans to bind the SDK 3.1?

ytn3rd commented Oct 4, 2012

I did find some errors with the bindings, I'll try fix them and see whats new in 3.1.

Version 3.1 have Native UIs

ytn3rd commented Oct 4, 2012

Yeah had just seen that. Will look into it over the weekend.

Do you have some news about SDK3.1?

Contributor

sblom commented Oct 21, 2012

I'm not working on bindings for 3.1 yet, and I'm not sure when I'll have time to do that. I think for now, my application will stick with 3.0. Do you know how much of the API surface changed with 3.1? Was it mostly just behavior changes?

If it's just behavior changes (which I kinda suspect), you can probably use these bindings with the new static lib files and things should mostly work. File specific issues if you encounter any problems.

Scott,

I work with C# for many years, but I’m completely newbie with Monotouch.
Do you know some tutorial or blog that can help me understand how can I do these bindings?
Maybe, some time in future, I can help you guys with that too!

Best regards,

Henrique

From: Scott Blomquist [mailto:notifications@github.com]
Sent: domingo, 21 de outubro de 2012 14:42
To: mono/monotouch-bindings
Cc: Mário Henrique Lopes Duarte
Subject: Re: [monotouch-bindings] DON'T PULL YET: Facebook iOS SDK 3.0 bindings (#53)

I'm not working on bindings for 3.1 yet, and I'm not sure when I'll have time to do that. I think for now, my application will stick with 3.0. Do you know how much of the API surface changed with 3.1? Was it mostly just behavior changes?

If it's just behavior changes (which I kinda suspect), you can probably use these bindings with the new static lib files and things should mostly work. File specific issues if you encounter any problems.


Reply to this email directly or view it on GitHubhttps://github.com/mono/monotouch-bindings/pull/53#issuecomment-9644624.

m8rge commented Dec 10, 2012

@ytn3rd do you fixed issues, which you describe here #53 (comment) ? Although, which bindings are better: https://github.com/ytn3rd/facebook-monotouch-samples/tree/master/binding or https://github.com/mono/monotouch-bindings/pull/53/files ? I want fork and add sdk3.1 support

Will appreciate an update on Facebook 3.1 bindings for iOS. Everytime I go to the Facebook developer page, it reminds me of upgrading to 3.1 and would like that warning to go away.

Besides, native Facebook GUIs would be nice if that is indeed the feature from 3.1 SDK.
thanks.

ytn3rd commented Dec 16, 2012

Sorry guys, but never got around to it.
Surely the bindings can't be too different. But as for if you wanted to fork one, I'd go with the current MT bindings (not pull53) and then look at pull 53 and see what needs to go in. Current MT bindings handle the lack of ARMv6. I will most definitely start looking into this tonight though.

ytn3rd commented Dec 16, 2012

The most up to date bindings I had was here,
https://github.com/ytn3rd/facebook-monotouch-samples/tree/master/binding

Which I have copied/pasted (but commented out) to
https://github.com/ytn3rd/monotouch-bindings/tree/master/facebook/binding

I have had a look at some of the new things that need bindings but I have no idea what they are, or how to bind them :(

Like

typedef void (^FBModalCompletionHandler)(FBViewController *sender, BOOL donePressed);

from FBViewController.h

Owner

migueldeicaza commented Jan 16, 2013

Hello,

To bind the above, use:

delegate void FBModalCompletionHandler (FBViewController sender, bool donePressed)

And then you can use the FBModalCompletionHandler in the code.

I did a small update to the facebook bindings today, since there was another pull request. Do you mind updating your bindings

Hi,

anyone know that state of this binding? I updated and rebuilt, but my existing code breaks because FBSessionDelegate is no longer available.

I try the Scrumptious sample, which throws an exception of:

[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:]: unrecognized selector sent to class 0x3106ec

This is from the iOS simulator (running iOS 6.0).

Any help would be greatly appreciated.

Thanks.

Member

dalexsoto commented Jan 31, 2013

@brettnagy weird that works ok for me http://screencast.com/t/doqXgVOtLl what version of MonoTouch are you using?

@dalexsoto thanks for the follow-up.

MonoTouch 6.0.10
Mono 2.10.9
MonoDevelop 3.1.1

The Scrumptious sample is only supposed to work on iOS 6? Is this a limitation of the new FB SDK bindings?

Thanks again.

Ahh, looking at your screencast, I see you're using simulator 6.1.
I'm on 6.0.

Member

dalexsoto commented Jan 31, 2013

@brettnagybut the sample was done using 6.0, I did update to 6.1 this morning, also I dont really know if facebook sdk is iOS 6 only could not find any references to it :/

@dalexsoto maybe it's how I'm generating the facebook.dll via make?

Any way for you to share your facebook.dll?

Thanks!!

Member

dalexsoto commented Jan 31, 2013

mmm im using make too, this is really weird.

Member

dalexsoto commented Jan 31, 2013

let me do monotouch binding project for facebook hold on

Member

dalexsoto commented Jan 31, 2013

@dalexsoto interesting.

I built your solution, no problems, no errors. It produced the MonoTouch.FacebookConnect.dll

Then from the Scrumptious solution, I removed the reference to the previous facebook.dll and added the reference to this new MonoTouch.FacebookConnect.dll.

The error I get when I run Scrumptious in the simulator is:

Cannot cast from source type to destination type.
at MonoTouch.FacebookConnect.FBSession.get_ActiveSession () [0x00000] in :0
at Scrumptious.SCViewController.ViewWillAppear (Boolean animated) [0x00007] in /Users/brettnagy/Projects/MonotouchBindings/facebook/samples/Scrumptious/Scrumptious/SCViewController.cs:117

@dalexsoto I can try on a different machine in about three hours from now.

@dalexsoto I just reset my simulator ("Reset content and settings...) and the Scrumptious sample works!!

Previous session from a previous version of facebook.dll?

Now I have to see what kind of iOS 5.1 support this has...

Brett

Member

dalexsoto commented Feb 1, 2013

mmm.. I would suggest go with make Facebook.dll again just to see if monotouchbindings facebook works I really would appreciate it :)

Same error as last time. Specifically, this is the stack trace:

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: +[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:]: unrecognized selector sent to class 0x3106ec
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:bool_objc_msgSend_IntPtr_bool_IntPtr (intptr,intptr,intptr,bool,intptr)
at MonoTouch.FacebookConnect.FBSession.OpenActiveSession (System.String[] readPermissions, Boolean allowLoginUI, MonoTouch.FacebookConnect.FBSessionStateHandler completion) [0x00000] in :0

@dalexsoto and if the MonoTouch.FacebookConnect.dll version does work, will it work if our app was using the previous version of the monotouch fb bindings and still have an active session? I will probably be able to test that.

@migueldeicaza migueldeicaza reopened this Apr 2, 2013

Contributor

azchohfi commented Apr 23, 2013

Now it would be good to support SDK 3.5.
#133

Member

dalexsoto commented Apr 23, 2013

Yup, working on it ;)

Member

dalexsoto commented Apr 25, 2013

Done bindings are on version 3.5.1, please note I have not updated samples yet, but binding its up to date. Will update samples ASAP.

I have not tested them properly please if you encounter any errors let me know

See commit: 616e831

Member

dalexsoto commented May 30, 2013

New sample added showing Native Dialogs, iOS 5 support, FQL and Graph API see d721d74

Also improved a bit the usage of GraphObjects.

Hope this helps

Alex

ytn3rd commented Jul 26, 2013

I think bindings were fine for v3.5.3, but now v3.6 is out, fair sure it has changed a lot :(

Member

dalexsoto commented Sep 23, 2013

Updated bindings to version 3.8, hope you can test them, the binding can still be improved a little bit ;)

When I try to 'make' the newest version of the Facebook binding, it runs this:
"git clone git@github.com:facebook/facebook-ios-sdk.git && cd facebook-ios-sdk && git checkout tags/sdk-version-3.13.0"
and it's giving me 20 errors like this:
"obj/Release/ios/FacebookConnect/FBDialogs.g.cs(161,93): error CS0136: A local variable named result' cannot be declared in this scope because it would give a different meaning toresult', which is already used in a `parent or current' scope to denote something else"

Is there any way I can build the binding for version 3.12.0 of the SDK or some version that works?

@dalexsoto dalexsoto closed this Apr 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment