0

Azure MobileサービスでAzure Active Directoryを使用して認証するXamarin Formsアプリケーションを作成しました。これは私のWinPhoneアプリケーションでは動作しますが、iOSデバイスでは動作しません。これはiOSシミュレータでは動作しますが、実際のデバイスでは動作しません。私はアプリをデバイス上でクラッシュさせる正確な行に絞り込んだ。 AppDelegate.csファイルにあり、それは "App.Init(this)"の行です。それはどんなエラーも(少なくとも私が見ることができない)スローされません。それはシミュレータで正常に動作し、デバイスにデプロイして正常にインストールされます。しかし、あなたがそれを実行するためにデバイス上のアプリケーションをクリックすると、それはスプラッシュ画面を表示し、その後単に終了します。XamarinフォームiOSアプリケーションがAzure MobileサービスのActive Directory認証で動作しない

非常に関わっているhttps://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-usersの文書に従っており、それ以外はすべて動作します。

「App.Init(this)」が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; 
    } 


} 
+0

で確認してください。私はTodoAzureの例に続いて終了しました。https://github.com/xamarin/xamarin-forms-samples/tree/master/WebServices/TodoAzure Azure Docsの例が失敗した理由はわかりませんでしたが、移動したときIAuthenticateを独自のインタフェースに組み込み、プラットフォーム固有のコードを各プラットフォーム用の別々のクラスに分割しました(TodoAzureの例)。 – Stacy

答えて

0

紺碧のドキュメントには、独自の依存関係サービスへのインタフェースを分離、それは非常に明確に見えない(完全なコードは以下の通りです)。

喜んでそれを並べ替えることができます。別の参考文献を提供するには、書籍をhttp://aka.ms/zumobook

関連する問題