user2392891
user2392891

Reputation:

Send Facebook request from android does not show message preview and does not send to friends

In my android app, after the Facebook login and authentication, user is allowed to send the request to his friend to invite them to join the app. Moreover, I need to know who is invited, after the user sends requests.

My problems are as following:

  1. When user wants to send request, the message preview is not showing at the top of dialog box.
  2. When user tap on invite button, a black screen cover dialog box. if tap on black cover, it is disappearing.
  3. When user selects friends and tap on send, the request is not going to the friends.

Send request code is as following:

private void sendRequestDialog() {
    Bundle params = new Bundle();
    params.putString("message", "Learn how to make your Android apps social");
    WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(FBLoginActivity.this, Session.getActiveSession(), params))
            .setOnCompleteListener(new OnCompleteListener() {

                @Override
                public void onComplete(Bundle values, FacebookException error) {
                    if (error != null) {
                        if (error instanceof FacebookOperationCanceledException) {
                            Toast.makeText(FBLoginActivity.this, "Request cancelled", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(FBLoginActivity.this, "Network Error", Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        final String requestId = values.getString("request");
                        if (requestId != null) {
                            Toast.makeText(FBLoginActivity.this, "Request sent", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(FBLoginActivity.this, "Request cancelled", Toast.LENGTH_SHORT).show();
                        }
                    }
                }

            }).build();
    requestsDialog.show();
}

I followed the Facebook Send request implementation guide but I am not getting same result.

Note:

My application is not published on Play store yet.

App configuration on Facebook developer dashboard: Sand box disabled and it has not submitted to the Facebook for any permissions and approval.(I want to know for send request I need to do that?)

I am suspecting that I am missing some configuration on Facebook app dashboard.

I am appreciated for any help.

Upvotes: 1

Views: 1697

Answers (3)

user2392891
user2392891

Reputation:

Finally I got the answer. The missing point for sending request to friend from your app is to provide Facebook configuration to handle request properly which is not mentioned in Facebook documentation.

In Facebook dashboard, go the setting and add App on Facebook (Add platform section), facebook allocate a page in Facebook domain like https://apps.facebook.com/Your-name-space, then you could set your Canvas URL and Canvas Secure URL to bring the URL content to the canvas. (for more info about how to configure Canvas URL refer to [this][https://devcenter.heroku.com/articles/configuring-your-facebook-app-as-a-canvas-page]

After all when send request to friends, friends recieve notification and when click on it they will redirect to https://apps.facebook.com/Your-name-space.

Upvotes: 1

Prasanthi
Prasanthi

Reputation: 19

Ahmadi , Even i faced the similar issue . Later i fixed by disabling from sandboxmode and Providing Canvas URL in facebook app registration. If this answer is helpful reply back.

Upvotes: 0

Marcel Tricolici
Marcel Tricolici

Reputation: 440

Your code above doesn't have target/destination id. before sending a request you need to:

  1. Get the list of facebook friends (example here: Android: get facebook friends list)
  2. Show a dialog with friends... (an activity.. fragment.. or anything else.) and let user choose friend he want to invite (You need target user identifier ID)
  3. Send the request in the following way:

    Bundle postParams = new Bundle();

    postParams.putString("message", title);

    postParams.putString("data", message);

    postParams.putString("to", target);

    WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(getMainActivity(), Session.getActiveSession(), postParams)).setOnCompleteListener(new ApplicationRequestCallback()).build();

where ApplicationRequestCallback is a class that implements OnCompleteListener

Upvotes: 0

Related Questions