Start a new topic

Kinvey Android Facebook login is not working

I followed steps mentioned in below URL

http://devcenter.kinvey.com/android/guides/users#usingsocialidentities


Steps mentioned in this url belongs to old Facebook API. 



I even try your GIT URL:

https://github.com/KinveyApps/SignIn-Android


and gradle:

https://github.com/KinveyApps/SignIn-Android/blob/master/build.gradle


Here facebook sdk version is: 

compile 'com.facebook.android:facebook-android-sdk:3.23.1'


But latest version is: 4.7.0


So, the tutorial totally not working. And the documentation refers to old Facebook version. We are planning to use kinvey BAAS in our project but old documentation doesn't let us try the product.


Can you please provide latest documentation so that I do not have to waste my time on obsolete API's 


Thanks




Hello Surinder,


Our apologies for the delay in us updating our documentation.  The guide was a little outdated, but worked fine until the API version change at facebook a couple of months back.  I'll flag that article for an update to ensure that someone takes a look at it as soon as possible.


Thanks,

Thanks for a quick response. But in the mean time can you provide me any working facebook kinvey login, any git repo. I need to do a demo to the client. 


Regards

Surinder

Hi Surinder,


I have emailed you the link to a basic app separately.


I will outline the general steps here:

  1. Create the facebook app (quite a few clicks and then you get the facebook app id)
  2. Create the kinvey app (get the kinvey app id and app secret)
  3. Put following code in onCreate of your Activity (to launch Facebook LoginManager at app startup)

  

        FacebookSdk.sdkInitialize(this.getApplicationContext());
        mCallbackManager = CallbackManager.Factory.create();
        LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile"));
        LoginManager.getInstance().registerCallback(mCallbackManager,
                new FacebookCallback<LoginResult>() {
                    @Override
                    public void onSuccess(LoginResult loginResult) {
                        Log.d("KinveyAndroidFb", "Login");
                        AccessToken accessToken = AccessToken.getCurrentAccessToken();
                        Log.d("KinveyAndroidFb", accessToken.getToken());
                        final Client mKinveyClient = new Client.Builder("<kinvey-app-id-here>", "<kinvey-app-secret-here>", getApplicationContext()).build();
                        mKinveyClient.user().loginFacebook(accessToken.getToken(), new KinveyUserCallback() {
                            @Override
                            public void onFailure(Throwable e) {
                                Log.e("KinveyAndroidFb", "failed Kinvey facebook login", e);
                            }
                            @Override
                            public void onSuccess(User u) {
                                Log.d("KinveyAndroidFb", "successfully logged in with facebook");
                            }
                        });
                    }

                    @Override
                    public void onCancel() {
                        Toast.makeText(MainActivity.this, "Login Cancelled", Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void onError(FacebookException exception) {
                        Toast.makeText(MainActivity.this, exception.getMessage(), Toast.LENGTH_LONG).show();
                    }
                }); 

  


And as Damien said earlier, we will flag the documentation and the sample apps for update.


Regards,
Wani
Login or Signup to post a comment