2016-10-23 3 views
1

私のアプリでFacebookの友達にデータをリクエストして送信しようとしています。リクエストは正常に送信され、通知を受け取ります。しかし、通知のメッセージは私が指定したものではありません(xxxxxはあなたにリクエストを送信しました。私は5人の命を助けてください)。また、受け取ったリクエストのデータにアクセスすることはできません。ゲームリクエストID /アクセスFacebookのゲームリクエスト通知の内容

これは私がリクエストを送信しています方法です:

func sendLifeRequest(index: Int) { 
     let content = FBSDKGameRequestContent() 
     content.message = "Please help me with 5 lives" 
     content.data = "5lives" 
     let id = facebookFriends[index].id as NSString 
     var to: [NSString] = [NSString]() 
     to.append(id) 
     content.recipients = to 
     FBSDKGameRequestDialog.show(with: content, delegate: self) 
    } 

は、これは私がもう一方の端でそれを取得しようとしている方法です:

 FBSDKGraphRequest(graphPath: "https://graph.facebook.com/me/apprequests?access_token=" + FBSDKAccessToken.current().tokenString, parameters: nil).start(completionHandler: { (connection, user, requestError) -> Void in 
     print(requestError) // prints nil 
     print(user) 
    }) 

プリント(ユーザー)プリント:

Optional({ 
id = "https://graph.facebook.com/me/apprequests"; 
"og_object" =  { 
    id = xxxxxxxxxxxxx; 
    type = website; 
    "updated_time" = "2016-10-19T05:32:20+0000"; 
}; 
share =  { 
    "comment_count" = 0; 
    "share_count" = 0; 
}; 

更新:私はリクエストIDをコピーしてコピーするとグラフのパスのために動作します。誰もが受信機からこのIDを取得する方法を

func gameRequestDialog(_ gameRequestDialog: FBSDKGameRequestDialog!, didCompleteWithResults results: [AnyHashable : Any]!) { 
    print("request sent") 
    print(results) // copied ID from here 
} 

と貼り付けを終了知っているん...

FBSDKGraphRequest(graphPath: THE ID HERE, parameters: nil).start(completionHandler: { (connection, user, requestError) -> Void in 
    print(requestError) // prints nil 
    print(user) 
}) 

は現在、ユーザーのプリントを印刷:

Optional({ 
application =  { 
    category = Games; 
    id = xxxxxxxxxxxx; 
    link = "https://www.facebook.com/games/?app_id=1841299476156545"; 
    name = "Crazy Traffic Saga"; 
}; 
"created_time" = "2016-10-24T21:25:34+0000"; 
data = 5lives; 
from =  { 
    id = xxxxxxxxxxxx; 
    name = "xxxxxxxxxxxxxx"; 
}; 
id = xxxxxxxxxxxx; 
message = "Please help me with 5 lives"; 

})

問題私はあなたが送信し、ユーザーの受信にコピーされたユーザーと一緒にログインするとコピーされます。私はまだ受信者からのコードだけでアクセスすることはできません。ゲームのリクエストに応じて

Facebookのドキュメントは言う:

「受信者のユーザーアクセストークンを用いて、以下に示すように、グラフを照会することができるため、受信者のためのすべての要求を読み取るためにはこれは、要求IDのリストを返します。アプリでそのユーザーの。

は、私はそれを見つけた

+0

メッセージが通知宝石に示されていない、それが唯一のアプリの中央に示されています。 – CBroe

+0

うーん、ありがとう。受信側からどのようにデータにアクセスすることができますか? @CBroe – toiavalle

答えて

1

... https://graph.facebook.com/me/apprequests?access_token=[USERアクセストークン]」

をGETしかし、私は最初に何をしていたかのthats。要求があるべき「/私は/ apprequests」そう

FBSDKGraphRequest(graphPath: "/me/apprequests", parameters: nil).start(completionHandler: { (connection, user, requestError) -> Void in 
}) 
関連する問題