Open facebook login screen in personal App and not in device browser

徘徊边缘 提交于 2019-12-22 09:47:23

问题


When Facebook app are installed on device and i am not log in. My own app opens facebook app when click on facebook login button.and if i am login on facebook app, my own app takes login details from facebook app and let me use login info. When i don't have facebook app installed on device, first time when i click on facebook login button in my own app it open facebook login page on default device browser and save my login credentials for next time. when next time i try to login it directly fetch login info.

issue is when i open facebook website on default device browser (say chrome)explicitly. i directly get login to the account which i have loges in from my own app.

browser is caching login data, i want to stop that.

So i want to open login dialog contain webview for facebook login when click on facebook button.

I have taken button in xml like below

<com.facebook.login.widget.LoginButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    android:id="@+id/button_facebook_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

How can i achieve that?


回答1:


You have to do this in your code it will work for you.

LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_VIEW_ONLY); OR facebookLoginButton.setLoginBehavior(LoginBehavior.WEB_VIEW_ONLY);

For more info please see below link

https://developers.facebook.com/docs/reference/android/current/class/LoginBehavior/




回答2:


For FaceBook add this tag to your Manifest.XML file

<activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>

and get fb_login_protocol_scheme value from the app dashboard in facebook developers



来源:https://stackoverflow.com/questions/43367634/open-facebook-login-screen-in-personal-app-and-not-in-device-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!