下記の通りの問題が起きて、Xamarin FormでFacebook認証がうまくいきません。
どなたか対処法をご存知の方、ご教授願います。
よろしくお願い致します。
■やろうとしたこと
Xamarin Formsで、Faccebook認証するアプリを作成しています。
下記MSのチュートリアルに基づいて作成しています。
https://docs.microsoft.com/ja-jp/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-users
■問題点
DroidプロジェクトのMainActivityクラス、public async Task<bool> Authenticate()メソッドの下記の部分でエラーが出ます。
・ソース
// Sign in with Facebook login using a server-managed flow.
user = await TodoItemManager.DefaultManager.CurrentClient.LoginAsync(this,
MobileServiceAuthenticationProvider.Facebook);
・エラーメッセージ
エラー一覧をみると、下記のメッセージが出てきました。
エラー CS1503 引数 1: は 'testproject.Droid.MainActivity' から 'Microsoft.WindowsAzure.MobileServices.MobileServiceAuthenticationProvider' へ変換することはできません。 testproject.Droid F:\testproject_Xamarin_Forms (1)\Droid\MainActivity.cs 58 アクティブ
エラー CS1503 引数 2: は 'Microsoft.WindowsAzure.MobileServices.MobileServiceAuthenticationProvider' から 'Newtonsoft.Json.Linq.JObject' へ変換することはできません。 testproject.Droid F:\testproject_Xamarin_Forms (1)\Droid\MainActivity.cs 59 アクティブ
■調査内容
TodoItemManagerクラスのMobileServiceClientがおかしいのだろうと思って、調べてみました。
「using Microsoft.WindowsAzure.MobileServices;」はしていました。
ソースは、下記の通りです。
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.MobileServices;
#if OFFLINE_SYNC_ENABLED
using Microsoft.WindowsAzure.MobileServices.SQLiteStore;
using Microsoft.WindowsAzure.MobileServices.Sync;
#endif
namespace testproject
{
public partial class TodoItemManager
{
static TodoItemManager defaultInstance = new TodoItemManager();
MobileServiceClient client;
#if OFFLINE_SYNC_ENABLED
IMobileServiceSyncTable<TodoItem> todoTable;
#else
IMobileServiceTable<TodoItem> todoTable;
#endif
const string offlineDbPath = @"localstore.db"; private TodoItemManager() { this.client = new MobileServiceClient(Constants.ApplicationURL);
#if OFFLINE_SYNC_ENABLED
var store = new MobileServiceSQLiteStore(offlineDbPath);
store.DefineTable<TodoItem>();
//Initializes the SyncContext using the default IMobileServiceSyncHandler. this.client.SyncContext.InitializeAsync(store); this.todoTable = client.GetSyncTable<TodoItem>();
#else
this.todoTable = client.GetTable<TodoItem>();
#endif
}
public static TodoItemManager DefaultManager { get { return defaultInstance; } private set { defaultInstance = value; } } public MobileServiceClient CurrentClient { get { return client; } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/05 12:05
2017/08/18 07:58
2017/09/03 22:42