Facebook iOs sdk iphone : Call from multiple viewcontroller

前端 未结 2 1298
生来不讨喜
生来不讨喜 2020-12-15 13:59

i followed the official guide from facebook dev doc for implementing SSO from my iphone app, but all is in the same viewcontroller who hold istance of \"Facebook\" class. No

相关标签:
2条回答
  • 2020-12-15 14:42

    I just did this:

    in the YourApp_AppDelegate.h

    #import "FBConnect.h"
    
    Facebook *facebook;
    
    @property (nonatomic, retain) Facebook *facebook;
    

    In the YourApp_AppDelegate.m

    @synthesize facebook;
    

    Then in your application didFinishLaunchingWithOptions: function:

    facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_API"];
    

    From your viewController.h (any of them),

    #import "YourApp_AppDelegate.h"
    
    YourApp_AppDelegate *appDelegate;
    

    And then, in your viewController.m viewDidLoad function:

    appDelegate = (YourApp_AppDelegate *)[[UIApplication sharedApplication] delegate];
    

    Now, anytime you want to refer to your Facebook singleton, just refer to it like:

    [appDelegate.facebook authorize:nil delegate:self];
    
    0 讨论(0)
  • 2020-12-15 14:53
    facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_API" andDelegate:self];
    

    Thats how it looks like on my code :)

    0 讨论(0)
提交回复
热议问题