Reputation: 2799
I'm trying to create a application were you can "invite" or tell your friends about it through the Facebook request dialog. https://developers.facebook.com/docs/howtos/androidsdk/3.0/send-requests/
It works somewhat but one thing I need is to know who the requests were sent TO. How can I do this?
I also have a secondary issue where the request notification only shows up on the users app - not on the desktop page. Anyone know anything about that?
Request code:
private void sendRequestDialog() {
Bundle params = new Bundle();
params.putString("message", "!");
WebDialog requestsDialog = (
new WebDialog.RequestsDialogBuilder(MyPage.this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Toast.makeText(MyPage.this,
"Inbjudan avbruten",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MyPage.this, "Nätverksfel, kontrollera din anslutning och försök igen", Toast.LENGTH_SHORT).show();
}
} else {
final String requestId = values.getString("request");
if (requestId != null) {
Toast.makeText(MyPage.this, "Inbjudan skickad", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MyPage.this, "Inbjudan avbruten", Toast.LENGTH_SHORT).show();
}
}
}
})
.build();
requestsDialog.show();
}
If anyone can help me with this I'm very grateful! Thank you
Upvotes: 3
Views: 576
Reputation: 1888
Sorry about indentation
Bundle params = new Bundle();
RequestsDialogBuilder builder = new WebDialog.RequestsDialogBuilder(activity, Session.getActiveSession(), params);
builder.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
if (error == null) {
if (values.containsKey("request")) {
Set<String> keys = values.keySet();
for(String key:keys) {
if(key.contains("to[")) {
//I know this keys are horrible, but that's how facebook did it
//Here you have the id's to do something with it
Logger.d("FACEBOOK", "key " + key + " vlaue " + values.getString(key));
}
}
} else {
if (listener instanceof IFacebookCancelableListener) {
((IFacebookCancelableListener) listener).onCancel();
}
}
} else if (error instanceof FacebookOperationCanceledException) {
if (listener instanceof IFacebookCancelableListener) {
((IFacebookCancelableListener) listener).onCancel();
}
} else {
//Error
}
}
});
WebDialog dialog = builder.build();
dialog.show();
Upvotes: 3