首页 > 解决方案 > Xamarin Forms,Onedrive 在 iOS 上不工作,但在 Android 和 UWP 上工作

问题描述

我希望有人可以帮助我设置从 Xamarin Forms 应用程序连接到 OneDrive。我知道有很多可以找到的例子,但这些似乎已经过时了。他们都不再工作了。

因此,我尝试了适用于 UWP 和 Android 但不适用于 iOS 的 Xamarin.OneDrive。

我在 iOS 上采取的步骤:

Added 'com.microsoft.adalcache' to the keychain group in Entitlements.plist

Added the following code in appdelegate.cs

    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
    {
        Xamarin.OneDrive.Connector.SetAuthenticationContinuationEventArgs(url);
        return true;
    }

Added the following to plist.info with the correct Bundlename and Appid

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string><BUNDLENAME></string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string><APPID></string>
        </array>
    </dict>
</array>

Under iOS Bundle Signing I selected Manual Provisioning and selected Entitlements.plist in Custom Entitlements

在模拟器或物理设备上运行应用程序会导致显示以下错误:

System.Exception: Internal Server Error
System.ArgumentNullException: Value cannot be null.
Parameter name: viewController
at Microsoft.Identity.Client.AcquireTokenInteractiveParameterBuilder.WithParentActivityOrWindow (UIKit.UIViewController viewController) [0x00003] in :0
at Xamarin.OneDrive.DependencyImplementation.GetAuthResult (Microsoft.Identity.Client.IPublicClientApplication client, Xamarin.OneDrive.Configs configs) [0x00093] in <702bbb93f52d451c89c8adacbd52d653>:0
at Xamarin.OneDrive.Token.AcquireAsync () [0x00091] in <702bbb93f52d451c89c8adacbd52d653>:0
at Xamarin.OneDrive.Token.ConnectAsync () [0x000f0] in <702bbb93f52d451c89c8adacbd52d653>:0
at Xamarin.OneDrive.ConnectorHandler.InnerConnectionHandlerAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00161] in <702bbb93f52d451c89c8adacbd52d653>:0 

我不知道如何继续。

有人能告诉我如何让它在 iOS 上运行吗?

提前致谢 !

标签: xamarin.forms

解决方案


推荐阅读