簡體   English   中英

如何在 Xamarin.iOS 中使用 Google 的人員 API?

[英]How can I use Google's people API in Xamarin.iOS?

我必須在我們的 Xamarin 中訪問 Google 聯系人。 ios 應用程序所以,我們已經在谷歌開發者門戶中生成了谷歌的人 API 密鑰和客戶端 ID 但我不知道如何在 Xamarin.ios 應用程序中使用 API。 我們需要使用 API 獲取 Google 的聯系方式。 我們在 Google 文檔中獲得了一些 .net 代碼,但不幸的是,它在 Xamarin.ios 平台上不起作用。 xamarin 平台不支持 DLL。 請幫我解決這個問題。

我已經通過使用 Xamarin.Auth 庫解決了它。

Auth = new OAuth2Authenticator(
             Configuration.ClientId,
             string.Empty,
             "https://www.googleapis.com/auth/contacts",
             new Uri("https://accounts.google.com/o/oauth2/v2/auth"),
             new Uri(Configuration.RedirectUrl),
             new Uri("https://www.googleapis.com/oauth2/v4/token"),
             isUsingNativeUI: true);

            var viewController = Auth.GetUI();
            PresentViewController(viewController, true, null);

            Auth.Completed += Auth_Completed;
            Auth.Error += Auth_Error;



 private void Auth_Error(object sender, AuthenticatorErrorEventArgs e)
        {

        }



 private  void  Auth_Completed(object sender, AuthenticatorCompletedEventArgs e)
        {

            // SFSafariViewController doesn't dismiss itself
            DismissViewController(true, null);

            if (e.IsAuthenticated)
            {
            }
     }

必須在 Appdelegate.cs 中實現 OpentUrl() 直到 iOS 12 及更高版本 iOS 13 在 SceneDelegate.cs 中實現 OpenUrlContexts() 方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM