私は現在、ユーザーが Facebook の友達を招待できるようにするアプリケーションの機能を開発しています。そのために、ユーザーとその友達は報酬/ギフトを受け取ることができます。
そのため、Facebook リクエスト オプションを使用します。そこで、次の 2 つのドキュメントを調べました。
https://developers.facebook.com/docs/android/send-requests/
https://developers.facebook.com/docs/android/app-link-requests/
両方のデバイスにアプリケーションがインストールされていて、あるデバイスから別のデバイスにリクエストを送信し、送信者がこのメソッドを使用して送信した追加データを取得できる場合、これはうまく機能します。
private void getRequestData(final String inRequestId) {
// Create a new request for an HTTP GET with the
// request ID as the Graph path.
Request request = new Request(Session.getActiveSession(),
inRequestId, null, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
// Process the returned response
GraphObject graphObject = response.getGraphObject();
FacebookRequestError error = response.getError();
// Default message
String message = "Incoming request";
if (graphObject != null)
{
CupsLog.d(TAG, "getRequestData -> graphObject != null: "+ graphObject.toString());
// Check if there is extra data
if (graphObject.getProperty("data") != null)
{
CupsLog.d(TAG, "getRequestData -> graphObject.getProperty(data) != null");
try
{
// Get the data, parse info to get the key/value info
JSONObject dataObject = new JSONObject((String)graphObject.getProperty("data"));
// Get the value for the key - badge_of_awesomeness
String reward = dataObject.getString("reward");
// Get the value for the key - social_karma
String coffeeCups = dataObject.getString("coffee_cups");
// Get the sender's name
JSONObject fromObject = (JSONObject) graphObject.getProperty("from");
String sender = fromObject.getString("name");
String title = sender+" sent you a gift";
// Create the text for the alert based on the sender
// and the data
message = title + "\n\n" +
"reward: " + reward +
" coffeeCups: " + coffeeCups;
} catch (JSONException e) {
message = "Error getting request info";
}
} else if (error != null) {
message = "Error getting request info";
}
else
{
CupsLog.d(TAG, "getRequestData -> graphObject.getProperty(data) == null");
}
}
Toast.makeText(SocialFeaturesActivity.this, message, Toast.LENGTH_LONG).show();
}
});
// Execute the request asynchronously.
Request.executeBatchAsync(request);
}
質問:受信者が Facebook でこのリクエストを受け取り、それをインストールしない場合、このリクエストは彼を Google Play にリダイレクトしてアプリをインストールします。アプリをインストールして初めて開いた後ですか? とにかくこのデータを受け取る方法はありますか?