工作窗体应用程序,使用Azure的Active Directory的验证到一Azure的移动服务。这适用于我的WinPhone应用程序,但它不适用于iOS设备。它适用于iOS模拟器,但不适用于实际设备。我已缩小到导致应用在设备上崩溃的确切行。它是在AppDelegate.cs文件,它是“App.Init(本)”行。它不会抛出任何错误(至少不是我能看到的)。它在模拟器中运行良好,它可以在设备上部署和安装。然而,当你点击该应用的设备上运行它,它会显示启动画面,然后只是简单的退出。Xamarin窗体iOS应用程序不能与我创建了一个Xamarin Azure的移动服务Active Directory认证
我也跟着在https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-users的文档是非常复杂的和其他一切工作。
任何人都可以阐明为什么“App.Init(本)”将在iOS版AppDelegate.cs文件失败一些轻?它是实现IAuthenticate进行(完整的代码如下)
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate, IAuthenticate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
//App.Init(this); //If I uncomment this line, the app crashes. Leaving this line commented, the app doesn't every do the login/authentication.
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
// Define a authenticated user.
private MobileServiceUser user;
public async Task<bool> Authenticate()
{
var success = false;
var message = string.Empty;
try
{
// Sign in with Facebook login using a server-managed flow.
if (user == null)
{
user = await FormDataManager.DefaultManager.CurrentClient
.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController,
MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
if (user != null)
{
message = string.Format("You are now signed-in as {0}.", user.UserId);
success = true;
}
}
}
catch (Exception ex)
{
message = ex.Message;
}
// Display the success or failure message.
UIAlertView avAlert = new UIAlertView("Sign-in result", message, null, "OK", null);
avAlert.Show();
return success;
}
}
好吧检查出的书。我结束了继TodoAzure例如https://github.com/xamarin/xamarin-forms-samples/tree/master/WebServices/TodoAzure 我无法弄清楚,为什么Azure的文档例如保持其失败的,但是当我感动在IAuthenticate进行伸到自己的接口和分离特定于平台的代码放到单独的类为每个平台(按照TodoAzure例子),现在一切工作。 – Stacy