2017-06-15 205 views
0

我試圖使用xamarin.auth像來實現我的應用程序谷歌登錄以下如何回到谷歌應用程序登錄後

var auth = new OAuth2Authenticator("284202576320-7kgdhaa5sgvkoe03jmmcv0p8lfdma306.apps.googleusercontent.com","cAZW7uegD-h2- 
                 tNMMf5q1UGQ","https://www.googleapis.com/auth/userinfo.email",new 
                 Uri("https://accounts.google.com/o/oauth2/auth"),new 
                 Uri("http://dev.myfav.restaurant/Account/LoginComplete"),new 
                 Uri("https://accounts.google.com/o/oauth2/token"),null,true) 
    { 
     AllowCancel = true,     
    }; 

,但完成的事件不觸發其登錄後會網頁: ( 我收到以下錯誤

enter image description here

我需要找回用戶到我的應用我怎樣才能做到這一點????任何人都可以幫助我在此請。

在此先感謝

回答

0

在iOS中,一旦你已經完成了身份驗證與Xamarin.Auth你只需要解散的viewController,你會在你的應用程序被放回。

你這樣做訂閱到Completed事件的OAuth2Authenticator

auth.Completed += (sender, e) => 
{ 
    DismissViewController(true, null); 
}; 
+0

芒卡使用本地UI(在最後一個參數ctor設置爲true),所以這不起作用。 – moljac

0

如果「原生UI」使用(在構造函數的最後一個參數設置爲true),這意味着外部/系統瀏覽器用於登錄而不是WebView。所以,在Android代替web視圖使用[鉻] CustomTabs和iOS代替的UIWebView(或WKWebView)SFSafariViewController被使用。

使用原生UI用戶離開你的應用程序,並返回到您的應用程序的唯一方法是應用聯(或深層鏈接),這需要完全不同的方法。

1日不能使用HTTP [S]方案redirect_url(OK Android上是可以的,但在iOS上沒有)。爲此使用自定義方案。

參見樣品[S](Xamarin.Forms ComicBook):

https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences

而在回購文檔:

https://github.com/xamarin/Xamarin.Auth/tree/master/docs

+0

好感謝您的回覆,我會做一個嘗試@moljac – Mounika

相關問題