问题
I am trying to send app request to my facebook friend after authentication by using the following code snippet.
public void sendApplicationRequest(final List<String> userIdList, final String message, final String title, final int requestCode) {
final Bundle parameters = new Bundle();
parameters.putString("title", title);
parameters.putString("message", message);
parameters.putInt("requestCode", requestCode);
parameters.putString("frictionless", "1");
String to = getListOfUsersAsString(userIdList);
if (to != null) {
parameters.putString("to", to);
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
WebDialog requestDialog = createRequestDialog(parameters);
requestDialog.setOwnerActivity(activity);
requestDialog.show();
}
});
}
private WebDialog createRequestDialog(final Bundle parameters) {
final int requestCode = parameters.getInt("requestCode");
return (
new WebDialog.Builder( activity, "apprequests", parameters))
.setOnCompleteListener(new WebDialog.OnCompleteListener() {
@Override
public void onComplete(Bundle bundle, FacebookException e) {
//...
}
}
).build();
}
The problem is, the dialog shows on top of my app's activity but it requires authentication again. When I enter my credentials and login to facebook on the dialog, everything works well but players have to log in on every app request again and again.
I have also tried the new GameRequestDialog and GameRequestContent API's but the result is the same.
Do you have an idea about what is the problem here which force me to authenticate again on every web dialog?
Correction : After authenticating on the web dialog for the first time, it never forces you to authenticate again. But still, players need to authenticate two times in total.
来源:https://stackoverflow.com/questions/57709126/facebook-android-sdk-graph-api-3-2-and-4-0-sending-app-request-issue