{"id":301,"date":"2016-07-19T12:09:41","date_gmt":"2016-07-19T04:09:41","guid":{"rendered":"https:\/\/antijava.prjlife.com\/?p=301"},"modified":"2016-07-19T12:11:46","modified_gmt":"2016-07-19T04:11:46","slug":"facebook-signin-practice-log","status":"publish","type":"post","link":"https:\/\/antijava.prjlife.com\/?p=301","title":{"rendered":"Facebook Signin Practice Log"},"content":{"rendered":"<p>Facebook signin ios<\/p>\n<p>Follow the official document procedure<br \/>\nhttps:\/\/developers.facebook.com\/docs\/facebook-login\/ios<\/p>\n<p>1.Download SDK and setup the environment<br \/>\nhttps:\/\/developers.facebook.com\/docs\/ios\/getting-started<\/p>\n<p>Create new Facebook app<br \/>\n<a href=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-299\" src=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2-300x127.png\" alt=\"1.FB app 2 of 2\" width=\"300\" height=\"127\" srcset=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2-300x127.png 300w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2-768x325.png 768w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2-1024x433.png 1024w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-2-of-2.png 1188w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-298\" src=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2-300x153.png\" alt=\"1.FB app 1 of 2\" width=\"300\" height=\"153\" srcset=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2-300x153.png 300w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2-768x391.png 768w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2-1024x521.png 1024w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/1.FB-app-1-of-2.png 1165w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>2.Configure the XCode project parameters<br \/>\nInfo.plist<\/p>\n<p><a href=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/2.InfoPlist-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-302\" src=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/2.InfoPlist-1-300x246.png\" alt=\"2.InfoPlist\" width=\"300\" height=\"246\" srcset=\"https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/2.InfoPlist-1-300x246.png 300w, https:\/\/antijava.prjlife.com\/wp-content\/uploads\/2016\/07\/2.InfoPlist-1.png 544w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>For AppTransportSecurity parameters, you can follow the Facebook direction, or you can just &#8220;allow all&#8221; as follow<\/p>\n<p>&lt;key&gt;NSAppTransportSecurity&lt;\/key&gt;<br \/>\n&lt;dict&gt;<br \/>\n&lt;key&gt;NSAllowsArbitraryLoads&lt;\/key&gt;<br \/>\n&lt;true\/&gt;<br \/>\n&lt;\/dict&gt;<\/p>\n<p>3.Modify the source code<\/p>\n<p>3.1 AppDelegate<br \/>\n#import &lt;FBSDKCoreKit\/FBSDKCoreKit.h&gt;<\/p>\n<p>&#8211; (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {<br \/>\n[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];<br \/>\n&#8230;.<br \/>\n}<\/p>\n<p>3.2 ViewController you want to do Facebook Signin<br \/>\n#import &lt;FBSDKCoreKit\/FBSDKCoreKit.h&gt;<br \/>\n#import &lt;FBSDKLoginKit\/FBSDKLoginKit.h&gt;<\/p>\n<p>-(void)loginAsFacebook {<br \/>\nFBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];<br \/>\n[login logInWithReadPermissions:\u00a0 @[@&#8221;public_profile&#8221;, @&#8221;email&#8221;, @&#8221;user_friends&#8221;] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {<br \/>\nif (error) {<br \/>\nNSLog(@&#8221;Process error&#8221;);<br \/>\n} else if (result.isCancelled) {<br \/>\nNSLog(@&#8221;Cancelled&#8221;);<br \/>\n} else {<br \/>\nNSLog(@&#8221;Logged in&#8221;);<\/p>\n<p>NSLog(@&#8221;[%@][%@][%@][%@]&#8221;, [[FBSDKAccessToken currentAccessToken]appID],<br \/>\n[[FBSDKAccessToken currentAccessToken]userID],<br \/>\n[[FBSDKAccessToken currentAccessToken]refreshDate],<br \/>\n[[FBSDKAccessToken currentAccessToken]tokenString]<br \/>\n);<\/p>\n<p>\/\/Get some profile data<br \/>\nFBSDKGraphRequest *requestMe = [[FBSDKGraphRequest alloc]initWithGraphPath:@&#8221;me&#8221; parameters:@{@&#8221;fields&#8221;: @&#8221;email, first_name, last_name&#8221;}];<br \/>\nFBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];<br \/>\n[connection addRequest:requestMe completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {<br \/>\nif(result) {<br \/>\nNSString *sUserID, *sEmail, *sFirstName, *sLastName;<br \/>\nif ([result objectForKey:@&#8221;email&#8221;]) {<br \/>\nsEmail = [result objectForKey:@&#8221;email&#8221;];<br \/>\n}<br \/>\nif ([result objectForKey:@&#8221;first_name&#8221;]) {<br \/>\nsFirstName = [result objectForKey:@&#8221;first_name&#8221;];<br \/>\n}<br \/>\nif ([result objectForKey:@&#8221;last_name&#8221;]) {<br \/>\nsLastName = [result objectForKey:@&#8221;last_name&#8221;];<br \/>\n}<br \/>\nif ([result objectForKey:@&#8221;id&#8221;]) {<br \/>\nsUserID = [result objectForKey:@&#8221;id&#8221;];<br \/>\n}<\/p>\n<p>NSLog(@&#8221;Customer details:[%@][%@][%@][%@]&#8221;, sUserID, sFirstName, sLastName, sEmail);<\/p>\n<p>\/\/Facebook account was authenticated OK, do whatever you need<br \/>\n}];<br \/>\n[connection start];<br \/>\n}<br \/>\n}];<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Facebook signin ios Follow the official document procedure https:\/\/developers.facebook.com\/docs\/facebook-login\/ios 1.Download SDK and setup the environment https:\/\/developers.facebook.com\/docs\/ios\/getting-started Create new Facebook app 2.Configure the XCode project parameters Info.plist For AppTransportSecurity parameters, you can follow the Facebook direction, or you can just &#8220;allow &hellip; <a href=\"https:\/\/antijava.prjlife.com\/?p=301\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-ios-development"],"_links":{"self":[{"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301"}],"version-history":[{"count":0,"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=\/wp\/v2\/posts\/301\/revisions"}],"wp:attachment":[{"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/antijava.prjlife.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}