ios - Unable to get friendList -


var request = fbsdkgraphrequest(graphpath:"/me/friends", parameters: nil);  request.startwithcompletionhandler { (connection : fbsdkgraphrequestconnection!, result : anyobject!, error : nserror!) -> void in     if error == nil {         println("friends : \(result)")     } else {         println("error getting friends \(error)");     } 

-----------------------------------my log-------------------------

friends : {     data =     (     );     summary =     {         "total_count" = 714;     }; } 

how fetch facebook friends of user using app . please help. appreatiated . thankx in advance .

you cannot directly friends facebook because won't allow these. can following stuff won't able facebook id friends can names , profile pic

note : need approval facebook use taggable_friends.

var request = fbsdkgraphrequest(graphpath:"/me/taggable_friends", parameters: nil); 

you need check below permissions granted or not can check friends list.

if (fbsession.activesession.state == fbsessionstateopen             || fbsession.activesession.state == fbsessionstateopentokenextended)         {             [self loadfacebookfriends];         }         else         {             [fbsession openactivesessionwithreadpermissions:@[@"public_profile,email,user_friends"] allowloginui:yes completionhandler:              ^(fbsession *session, fbsessionstate state, nserror *error)              {                  if (!error)                  {                      if (state == fbsessionstateopen)                      {                          [fbsession setactivesession:session];                           [self loadfacebookfriends];                       }                      else                      {                          nslog(@"status :%ld",(unsigned long)state);                      }                  }                  else                  {                      // not connect                  }              }];         } -(void)loadfacebookfriends {     // send request friend lists     fbrequest* friendsrequest = [fbrequest requestforgraphpath:@"/me/friends"];     [friendsrequest startwithcompletionhandler: ^(fbrequestconnection *connection,nsdictionary* result,nserror *error)      {          [appdelegate activityhide];           if (error)          {              return ;          }           nsarray* friends = [result objectforkey:@"data"];          nslog(@"found: %lu friends", (unsigned long)friends.count);      }]; } 

**note : if using ios 9 need give following permissions app in info.plist. can refer link https://developers.facebook.com/docs/ios/ios9 **

add below transport securtiy in info.plist

<key>nsapptransportsecurity</key> <dict>     <key>nsexceptiondomains</key>     <dict>         <key>graph.facebook.com</key>         <dict>             <key>nsincludessubdomains</key>             <true/>             <key>nsexceptionrequiresforwardsecrecy</key>             <false/>             <key>nsexceptionallowsinsecurehttploads</key>             <true/>         </dict>         <key>facebook.com</key>         <dict>             <key>nsincludessubdomains</key>             <true/>             <key>nsexceptionrequiresforwardsecrecy</key>             <false/>             <key>nsexceptionallowsinsecurehttploads</key>             <true/>         </dict>         <key>fbcdn.net</key>         <dict>             <key>nsincludessubdomains</key>             <true/>             <key>nsexceptionrequiresforwardsecrecy</key>             <false/>         </dict>         <key>akamaihd.net</key>         <dict>             <key>nsincludessubdomains</key>             <true/>             <key>nsexceptionrequiresforwardsecrecy</key>             <false/>         </dict>     </dict> </dict> <key>lsapplicationqueriesschemes</key> <array>     <string>fbapi</string>     <string>fbapi20130214</string>     <string>fbapi20130410</string>     <string>fbapi20130702</string>     <string>fbapi20131010</string>     <string>fbapi20131219</string>     <string>fbapi20140410</string>     <string>fbapi20140116</string>     <string>fbapi20150313</string>     <string>fbapi20150629</string>     <string>fbauth</string>     <string>fbauth2</string>     <string>fb-messenger-api20140430</string>     <string>fb-messenger-platform-20150128</string>     <string>fb-messenger-platform-20150218</string>     <string>fb-messenger-platform-20150305</string> </array> 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -