i am working on facebook sdk 3.0 in android and need to send request to friends and my code is :-
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("message",
"Learn how to make your Android apps social");
WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(
Logout.this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,
FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(
Logout.this.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
Logout.this.getApplicationContext(),
"Network Error", Toast.LENGTH_SHORT)
.show();
}
} else {
final String requestId = values
.getString("request");
if (requestId != null) {
Toast.makeText(
Logout.this.getApplicationContext(),
"Request sent", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(
Logout.this.getApplicationContext(),
"Request cancelled", Toast.LENGTH_SHORT)
.show();
}
}
}
}).build();
requestsDialog.show();
}
when i am clicking on Send button Toast is coming for request send but request is not coming to friends and no notification coming to that friend but i need this i am no getting what is problum please help me;)
您需要在Bundle参数中添加您朋友的Facebook ID。
params.putString("to", uid);
private void sendInviteDialog(String uid,final int position) {
Bundle params = new Bundle();
params.putString("to", uid);
params.putString("message", "Please try my app");
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(getActivity(),
Session.getActiveSession(),
params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values,FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
MessageUtil.showMessage( "Request cancelled", true);
} else {
MessageUtil.showMessage( ResourcesUtil.getString(R.string.network_unavailable), true);
}
} else {
final String requestId = values.getString("request");
if (requestId != null) {
MessageUtil.showMessage( ResourcesUtil.getString(R.string.friend_request_sent), true);
} else {
MessageUtil.showMessage(ResourcesUtil.getString(R.string.request_not_successful), true);
}
}
mProgressDialog.dismiss();
}
})
.build();
requestsDialog.show();
}
那是因为您的应用程序处于沙盒模式,请禁用沙盒模式。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.