Reputation: 183
It shows the correct number of friends that are using the app, however, when I go to use "/app/scores" to get my friends' scores, it only returns 2 of them.
Here's the code for getting my friends:
func getFriends() {
FBRequestConnection.startWithGraphPath("/me/friends", parameters: nil, HTTPMethod: "GET", completionHandler: {(connect: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
var dict = result as NSDictionary
println("Dict: \(dict)")
})
}
The output is as is:
Dict: {
data = (
{
id = 10204187717756755;
name = "Hardeep Singh";
},
{
id = 629290707196986;
name = "Ishy Singh";
},
{
id = 1572289319655654;
name = "Ashlee Carter";
}
);
Then to get my friends' scores, I'm using this code:
FBRequestConnection.startWithGraphPath("/app/scores", parameters: nil, HTTPMethod: "GET", completionHandler: {(connection: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
var resultdict = result as NSDictionary!
let userDefaults = NSUserDefaults.standardUserDefaults()
var data: NSArray! = resultdict.objectForKey("data") as NSArray!
var int = data.count as Int
println("Dict: \(resultdict)")
//println("Int: \(int)")
for (var i = 0; i < int; i++) {
let packet: NSMutableDictionary = data.objectAtIndex(i) as NSMutableDictionary
let score = packet.objectForKey("score") as Int
var scoreStr = String(score)
self.scoreArray.addObject(score)
let user: NSMutableDictionary = packet.objectForKey("user") as NSMutableDictionary
let name = user.objectForKey("name") as String
if (self.name == name) {
let highScore = score
userDefaults.setValue(highScore, forKey: "fbHighScore")
}
self.nameArray.addObject(name)
self.globalDict.setValue(scoreStr, forKey: name)
}
userDefaults.setValue(self.nameArray, forKey: "nameArray")
userDefaults.setValue(self.scoreArray, forKey: "scoreArray")
userDefaults.setValue(self.globalDict, forKey: "dict")
println("Scores: \(self.globalDict)")
})
Which yields this output:
Scores: {
"Ishy Singh" = 20;
"Sunny Singh" = 6;
}
So, I don't know how I'm going from have 3 friends who use the app, to only getting my score and 1 others score. I've followed every Facebook documentation and Googled pretty much everything I can think of, but no luck. Any suggestions?
Upvotes: 1
Views: 435
Reputation: 183
I found the answer. The users that weren't showing had a privacy of 'Only Me' for the app publish settings, and when I changed the setting to 'Friends', it worked.
Upvotes: 3