当Chrome被禁用/删除设备时,MS Graph无法打开新的浏览器活动

时间:2018-02-21 14:33:49

标签: android xamarin microsoft-graph

我开发了一个xamarin表单应用程序,它使用MS Graph以便用户登录。我使用了GitHub示例打开一个新的浏览器活动,用户登录然后应用程序转到主页活动。它工作正常。但是有些用户阻止或删除了Chrome应用,以便将MS Edge用作默认浏览器,然后当应用尝试启动浏览器活动时,它会启动错误,因为它无法找到Chrome活动。我已经问过MS Graph GitHub(https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/242),但他们和我认为这不是SDK的问题,但我不知道如何解决它。我应该如何修复它才能使用任何已安装的浏览器?

谢谢

2 个答案:

答案 0 :(得分:2)

它是通过设计完成的。 Microsoft Identity Client库使用自定义Chrome选项卡,并且没有任何后备策略可以使用WebView运行。

如果找不到Chrome,您可能会遇到此异常:https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/dev/src/Microsoft.Identity.Client/Platforms/Android/AuthenticationActivity.cs#L131

string chromePackageWithCustomTabSupport = GetChromePackageWithCustomTabSupport(ApplicationContext);

if (string.IsNullOrEmpty(chromePackageWithCustomTabSupport))
{
    string chromePackage = GetChromePackage();
    if (string.IsNullOrEmpty(chromePackage))
    {
        throw new MsalClientException(MsalClientException.ChromeNotInstalledError,
            "Chrome is not installed on the device, cannot proceed with authentication");
    }

答案 1 :(得分:1)

@Cheesebaron是正确的,这是设计的。目前,MSAL中的Xamarin Android只能启动chrome或chrome自定义标签。如果设备没有它们,它将导致异常,如上所述。

@ cansado2930错误消息pkg=com.android.chrome的这部分表示设备上未安装Chrome。

MSAL中的嵌入式webview支持将在不久的将来成为一种选择。

这是issue in the MSAL repo的链接。