简体   繁体   中英

ShareKit Connect with Facebook

I have an application where users need to login/create an account in order to use it. I am trying to implement Connect with Facebook through ShareKit 2.0. Do you know if this is possible and can you please point me in the right direction? Thanks

Yes you can use Facebook as a point of login to any app. Before doing that you need to register your app in Facebook Developers page. More info here : http://developers.facebook.com/

After creating an App entry in Facebook, save the App id for setting configuration in Sharekit.

Sharekit uses a defaultConfiguration file(where all configurations related to your app resides) and it recommends to override that class for setting your app-specific defines.

Link: https://github.com/ShareKit/ShareKit/wiki/Configuration

Once after Subclassing the configuation file, add your Facebook App id there. (I guess secret key is not required as its by default disabled after creating an Facebook app).

Once you login to Facebook via Sharekit,you will get the token(it will be saved in the NSUserdefaults with a key - @"kSHKFacebookAccessToken" ) and if you need more data from facebook, you can subclass SHKFacebook class and access data from Facebook with the access token.

For logging in via Sharekit to Facebook,You need to do this.

       SHKSharer *service = [[[SHKFacebook alloc] init] autorelease];
        if(![service authorize]) //This will prompt for login if token was not saved or if it got expired. 
        {
              service.shareDelegate = self; //implement the delegate so that once after login you will get to know when to fetch token.
        }
        else
        {
              //Directly access the token with the key in NSUserdefaults and use this.
        }

Hope this helps!

Update: If you want to use Sharekit only for this option(for FB Log-in), I would recommend to use Facebook SDK instead. Sharekit makes life easier for sharing among different Sharing services!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM