Friday, 8 November 2013

Log In with Facebook & Share Application With Simple Way For iOS.

For Facebook login , you should do 3 things :-
1. Using Singleton, Why?
Singleton allow you to access same variable or method in different page , since you will use Facebook class in their view , so start using singleton.
2. Core Part – Facebook iOS Class.
3. Delegate.
Facebook use delegate to do callback , as singleton is suggested to use , so we need to set up our own delegate for the views that are using access Facebook.

1. Firstly you create a new project  select Single View Application

2. Click next write name of the project For eg :- FacebookLogIn then click next 

3. Select path where you want to create the app & click Create.

4. Now first download Facebook SDK from here :-
https://github.com/preetlotey999/Download-Facebook-SDK-For-iOS
5. Drag & drop the SDK into your project. Make sure tick these options as shown below in the screen shot.

6. Now open your storyboard or xib drag & drop UIButton named Facebook Log In 

7. Create action of FBLogIn Button :-

8. Now give action to file owner 

9. Now write the code in UIButton action :-

10. Now set up APP ID of Facebook in Singleton.m 

11. Now this APP ID also set in info.plist :-

12. Now to handle the Facebook write this code in AppDelegate :-

For arc enabled project do this :-


Now Run The Code & Click On FB Button.
It will first open the session enter your Facebook username & password then login & share the application.

You can also download full code project from here :-

https://github.com/preetlotey999/Facebook-Log-In-and-Share-Application-For-iOS.git
Thanks Guys. If you like the code then post a comment & if you have any query regarding this code or you have any query then post your query on this Blog.  :)


No comments:

Post a Comment