1

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.

zoranc
  • 2,410
  • 1
  • 21
  • 34
  • By the way, I am searching a lot but I didn't find any proper response. –  Mar 10 '14 at 10:38

3 Answers3

1

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.

0

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

Community
  • 1
  • 1
Marcel Tricolici
  • 442
  • 3
  • 14
  • Thank you for your prompt reply. Your suggestion is not valid since the dialog retrieve the Facebook friends, see [this link](https://developers.facebook.com/docs/android/send-requests#step2). Even I set "to" attribute with some fb ids, the notification is not sent. –  Mar 11 '14 at 07:30
  • before sending please set OnCompleteListener and see what this method returns: onComplete(Bundle values, FacebookException error) ... is there any error? – Marcel Tricolici Mar 11 '14 at 12:01
  • I have already set onCompleteListener. The Error is null and Bundle contain request id and "to" attribute which indicate friends fbid. –  Mar 12 '14 at 07:00
  • I have already set onCompleteListener. The Error is null and Bundle contain request id and "to" attribute which indicate friends fbid. My problem is that the notification is not appear on friends Facebook. I am suspecting since request has no target (Redirect Url) it is not shown on friends Notification. I need to know first, where I need to set "redirect url". (It should be on Facebook dashboard because when I set it in params nothing happened, I could not find any documentation where I need to set) –  Mar 12 '14 at 07:22
  • @MarcelTricolici : i tried your code and i have also set onCompleteListener. when i sent any request to friend then it returns requestId also means that request sent successfully. but i cant show this friend request in my facebook friend request list. can you please help me to avoid this problem? Thankx in Advance :) – Ajay Apr 25 '14 at 13:39
  • This does not seem to work. Any clue? The requests are not sent. Thanks. – Juampa Dec 05 '14 at 21:12
  • where do I set the URI for the notification redirection ? – Francisco Corrales Morales Jan 12 '15 at 15:42
0

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.

Prasanthi
  • 19
  • 7
  • 1
    Could You please, elaborate more, how to do that? – Kamiccolo Mar 18 '14 at 13:36
  • @Prasanthi Thanks for your reply, if you mean that disabling from sandboxmide to make app public, it has already in public mode but regarding to the Canvas URL, I couldn't find any field with this name in Facebook dashboard. –  Mar 19 '14 at 01:42
  • Thank you Prasanthi for reminding me about Canvas URL, I searched and find the solution which will post here for others. However, you mentioned about canvas url, but it is not the proper answer. –  Mar 19 '14 at 02:09