ibrahim demir
ibrahim demir

Reputation: 461

Can't send app request to friend on facebook for android

I need to send my android application installation request to users' friends. Here is the sample code that I found on web. Everything works great here, I can select users then when I press Send Button, Toast shows that "Request sent". But I cant see the request on profile that I have sent request. What is wrong here?

public class InviteFriends extends Activity {
    Activity activity = this;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.main);
        sendRequestDialog();
    }
    private void sendRequestDialog() {
        Bundle params = new Bundle();
        params.putString("message", "Learn how to make your Android apps social");
        params.putString("frictionless", "1");

        WebDialog requestsDialog = (
                new WebDialog.RequestsDialogBuilder(activity,
                        Session.getActiveSession(),
                        params))
                .setOnCompleteListener(new WebDialog.OnCompleteListener() {

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

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

Upvotes: 1

Views: 1905

Answers (1)

ibrahim demir
ibrahim demir

Reputation: 461

I found my problem,

Here is the keypoint: Facebook SDK v3.0 Request Dialog not sending application request

"From this Facebook developers page: "User to User Requests are only available for Canvas apps""

And then I searched for what I am trying to do:

https://developers.facebook.com/docs/howtos/requests/#user_to_user

As a result, I added new platform(An application on facebook) on facebook developers page's dashboard settings. That's all, it is working now..

Upvotes: 1

Related Questions