gpt4 book ai didi

facebook - Xamarin:最新 FB API 的问题

转载 作者:行者123 更新时间:2023-11-30 05:22:50 24 4
gpt4 key购买 nike

最新FB登录API有3个参数

public unsafe virtual void LogInWithReadPermissions (string[] permissions, UIViewController fromViewController, [BlockProxy (typeof(Trampolines.NIDLoginManagerRequestTokenHandler))] LoginManagerRequestTokenHandler handler)

我正在使用 MVVMCross。对于 fb 登录,我尝试创建一个我所在的 View 的实例,并将其作为参数传递给 LogInWithReadPermissions()

View 模型:

private async void DoFacebookSignIn()
{
try
{
await facebookService. Login();
DoAutoLogin();
}
}

服务:

private readonly string[] permitions = new string[] { "email", "public_profile" };    
public async System.Threading.Tasks.Task LogIn()
{
LoginManager.LogInWithReadPermissionsAsync (permitions);

LoginManagerLoginResult result = await LogInWithReadPermissionsAsync();

if (result.IsCancelled)
{
ServiceFactory.UserMessageService.ShowToast("Facebook login is canceled");
}
}

private Task<LoginManagerLoginResult> LogInWithReadPermissionsAsync()
{
var tcs = new TaskCompletionSource<LoginManagerLoginResult> ();
LoginManager.LogInWithReadPermissions (permitions,null, (LoginManagerLoginResult result, NSError error) =>
{
if(error.IsNotNull ())
{
tcs.SetException (new IosErrorException(error));
} else
{
tcs.SetResult (result);
}
});

return tcs.Task;
}

但是它失败了,当我调用这个函数时,我是否需要从 Viewmodel 传递 View 信息?如何从 View 模型传递 View 实例?谁能帮忙?

更新

服务失败:

函数 LogInWithReadPermissionsAsync()第 3 行:(LoginManager.LogInWithReadPermissions...)

没有给出任何错误。它只是崩溃。Facebook API 版本:"Xamarin.Facebook.iOS"version="4.13.1"

更新删除了未使用的代码。

最佳答案

我得到了解决方案。

代码很好,我只需要通过添加

将“网络请求的 Facebook 服务器列入白名单”
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>

If you're recompiling with iOS SDK 9.0, add the following to your application's plist if you're using a version of the SDK v4.5 or older:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
</array>
If you're using Facebook.MessengerShareKit from versions older than the v4.6 release, also add:

<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>
If you're using v4.6.0 of the SDK, you only need to add:

<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>

如 Xamarin Facebook iOS SDK 中所述 here .

关于facebook - Xamarin:最新 FB API 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39169856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com