Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlutterQq.isQQInstalled() 方法不全面,无法支持TIM #11

Open
litang0908 opened this issue Aug 6, 2019 · 0 comments
Open

FlutterQq.isQQInstalled() 方法不全面,无法支持TIM #11

litang0908 opened this issue Aug 6, 2019 · 0 comments

Comments

@litang0908
Copy link
Contributor

感谢作者开发的这么好的lib,为我们使用QQ登录节省了好多时间 :)
不过,在使用中发现,只能使用QQ主版本进行登录,无法使用TIM或者QQ国际版登录,看内部实现代码是:

private void isQQInstalled(MethodCall call, Result result) {
        result.success(mTencent.isQQInstalled(registrar.activeContext()));
}

不过,其实TIM和QQ国际版目前也是支持使用QQ登录的,只是这个QQ的登录SDK内部,针对 isQQInstalled方法的实现,只支持了QQ主版本,没有支持TIM和QQ国际版。

public boolean isQQInstalled(Context var1) {
        PackageManager var2 = var1.getPackageManager();
        List var3 = var2.getInstalledPackages(0);
        if (var3 != null) {
            for(int var4 = 0; var4 < var3.size(); ++var4) {
                String var5 = ((PackageInfo)var3.get(var4)).packageName;
                if (var5.equals("com.tencent.mobileqq")) {
                    return true;
                }
            }
        }
        return false;
    }

经过我们项目中的实验,TIM和QQ国际版登录也是完全可以的,希望可以支持一下,以下是我们用来判断的代码:

public static boolean isQQInstall(Context context) {
        try {
            final PackageManager packageManager = context.getPackageManager();
            List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
            if (pinfo != null) {
                for (int i = 0; i < pinfo.size(); i++) {
                    String pn = pinfo.get(i).packageName;
                    if (pn.equals("com.tencent.mobileqq") //QQ
                            || pn.equals("com.tencent.mobileqqi")//QQ国际版
                            || pn.equals("com.tencent.tim")) {//TIM
                        return true;
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return false;
    }

目前为了支持TIM和QQ国际版,我们单独实现了Plugin来判断,希望这个lib也可以支持。
再次感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant