6

mới nhất API FB đăng nhập có ba thông sốXamarin: Vấn đề với FB API mới nhất

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

Tôi đang sử dụng MVVMCross. Đối với fb đăng nhập, tôi đã cố gắng tạo ra một thể hiện của quan điểm tôi đang ở, và vượt qua nó như một tham số cho LogInWithReadPermissions()

ViewModel:

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

DỊCH VỤ:

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; 
      } 

Nhưng lỗi của nó, tôi có cần phải chuyển thông tin xem từ ViewModel, khi tôi gọi func này? Làm thế nào để vượt qua trường hợp xem từ mô hình xem? Có ai giúp được không?

CẬP NHẬT

Nó không nhằm phục vụ:

func LogInWithReadPermissionsAsync() Line3: (LoginManager.LogInWithReadPermissions...)

mà không đưa ra bất kỳ lỗi. Nó chỉ bị rơi. Các Facebook API phiên bản: phiên bản "Xamarin.Facebook.iOS" = "4.13.1"

CẬP NHẬT Removed mã không sử dụng.

+0

Bạn phải rất cẩn thận về 'không đồng bộ void' nếu chúng không dành cho trình xử lý sự kiện. Thứ hai, bạn nên tải lên những gì chính xác là "không" ở đây. Bạn có ngoại lệ không? Liệu nó âm thầm thất bại? vv Cũng vui lòng đăng chính xác API FB bạn đang sử dụng cho dù đó là NuGet/Component/etc –

+0

Tôi đã cập nhật câu hỏi của mình với thông tin cần thiết chưa. – TheDeveloper

+0

Tải lên 'mcve' để giúp hiển thị những gì đang diễn ra: http://stackoverflow.com/help/mcve Thứ hai, bạn đã kiểm tra nhật ký thiết bị của mình để có thêm đầu ra chưa? https://kb.xamarin.com/customer/portal/articles/1675684-where-can-i-find-my-version-information-and-logs#debug-logs-for-xamarin-apps –

Trả lời

1

Tôi đã nhận được giải pháp.

Mã này là tốt Tôi chỉ cần thiết để 'Servers Whitelist Facebook cho yêu cầu Mạng' bằng cách thêm

<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> 

Như đã đề cập trong Xamarin Facebook iOS SDK here.

+0

Bạn có thể cho tôi biết FBSign làm gì trong bài đăng gốc không? Làm thế nào để nó có được bộ điều khiển xem :) – LamonteCristo

+0

@LamonteCristo, Đó là một bộ điều khiển xem ngẫu nhiên để tôi có thể vượt qua trong hàm LogInWithReadPermissions(). Không cần thiết, tôi đã cập nhật mã. Bạn có thể kiểm tra mã mới nhất. – TheDeveloper

Các vấn đề liên quan