如果Facebook本机应用程序安装在设备中,Facebook登录不起作用? [英] Facebook login not working if Facebook native application installed in device?

查看:258
本文介绍了如果Facebook本机应用程序安装在设备中,Facebook登录不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android应用程序工作。当facebook本机应用程序安装它不工作,并显示只有两个弹出窗口。但如果它没有安装它重定向到Facebook网站,工作正常。我如何解决这个问题。任何帮助将不胜感激。我已经检查并添加了所有的hashkey在Facebook应用程序。但仍然无法正常工作。

  statusCallback = new SessionStatusCallback(); 
会话session = Session.getActiveSession();
this.isLogin = isLoginUser;
session = null;
if(session == null){
if(savedInstanceState!= null){
session = Session.restoreSession(context,null,statusCallback,savedInstanceState);
}
if(session == null){

session = new Session.Builder(context).setApplicationId(
688998947797106)build();

}
Session.setActiveSession(session);
if(session.getState()。equals(SessionState.CREATED_TOKEN_LOADED)){
session.openForRead(new Session.OpenRequest(activity)
.setCallback(statusCallback)
.setLoginBehavior (
SessionLoginBehavior.SSO_WITH_FALLBACK)
.setPermissions(Arrays.asList(email)));
}
}
if(!session.isOpened()&!session.isClosed()){
session.openForRead(new Session.OpenRequest(activity)
.setCallback(statusCallback)
.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK)
.setPermissions(Arrays.asList(email)));
} else {
Session.openActiveSession(activity,true,statusCallback);
}


解决方案

我也有同样的问题,我添加了不同的键看我的问题这里



您将获得更多关于此讨论的信息点击这里请参阅该链接中由Abhishek Agrawal提供的答案。



将以下代码添加到活动onCreate并检查您的应用程序发送到Facebook的哈希键,

  PackageInfo信息; 
try {
info = getPackageManager()。getPackageInfo(com.example.yourpackagename,PackageManager.GET_SIGNATURES);
(签名签名:info.signatures){
MessageDigest md;
md = MessageDigest.getInstance(SHA);
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(),0));
// String something = new String(Base64.encodeBytes(md.digest()));
Log.e(hash key,something);
}
} catch(NameNotFoundException e1){
Log.e(name not found,e1.toString());
} catch(NoSuchAlgorithmException e){
Log.e(no such an algorithm,e.toString());
} catch(Exception e){
Log.e(exception,e.toString());
}


I am working on android Application. when facebook native application installed it does not work and show only two popup. but if itis not installed it redirect to facebook website and works fine .How i can resolve this . any help will be appreciated. I have checked and added all hashkey in facebook app. but still not working .

    statusCallback = new SessionStatusCallback();
    Session session = Session.getActiveSession();
    this.isLogin = isLoginUser;
    session = null;
    if (session == null) {
        if (savedInstanceState != null) {
            session = Session.restoreSession(context, null,                        statusCallback,savedInstanceState);
        }
        if (session == null) {

            session = new Session.Builder(context).setApplicationId(
                    "688998947797106").build();

        }
        Session.setActiveSession(session);
        if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
            session.openForRead(new Session.OpenRequest(activity)
                    .setCallback(statusCallback)
                    .setLoginBehavior(
                            SessionLoginBehavior.SSO_WITH_FALLBACK)
                    .setPermissions(Arrays.asList("email")));
        }
    }
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(activity)
                .setCallback(statusCallback)
                .setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK)
                .setPermissions(Arrays.asList("email")));
    } else {
        Session.openActiveSession(activity, true, statusCallback);
    }

解决方案

I also Had same problem, I have added different key. See my Question Here

You will get more Information on this discussion Click here See The answer given By Abhishek Agrawal in that Link.

Add following code to your Activities onCreate and check which hashkey is sent by your app to facebook,

PackageInfo info;
    try {
        info = getPackageManager().getPackageInfo("com.example.yourpackagename", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;
            md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String something = new String(Base64.encode(md.digest(), 0));
            //String something = new String(Base64.encodeBytes(md.digest()));
            Log.e("hash key", something);
        }
    } catch (NameNotFoundException e1) {
        Log.e("name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("no such an algorithm", e.toString());
    } catch (Exception e) {
        Log.e("exception", e.toString());
    }

这篇关于如果Facebook本机应用程序安装在设备中,Facebook登录不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆