6

नवीनतम अमेरिकन प्लान लॉगिन एपीआई तीन मापदंडोंXamarin: नवीनतम अमेरिकन प्लान एपीआई के साथ जारी करना

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

मैं MVVMCross का उपयोग कर रहा है।

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; 
      } 
अमेरिकन प्लान लॉगिन के लिए, मैं दृश्य मैं में हूँ, और LogInWithReadPermissions()

ViewModel के लिए एक पैरामीटर के रूप में यह पारित का एक उदाहरण बनाया की कोशिश की

लेकिन इसकी असफलता, क्या मुझे व्यूमोडेल से दृश्य जानकारी पास करने की आवश्यकता है, जब मैं इस func को कॉल कर रहा हूं? दृश्य मॉडल से दृश्य उदाहरण कैसे पास करें? क्या कोई मदद कर सकता है?

अद्यतन

यह सेवा में नाकाम रहने के है:

समारोह LogInWithReadPermissionsAsync() पंक्ति 3: (LoginManager.LogInWithReadPermissions...)

किसी भी त्रुटि नहीं दिया। यह सिर्फ दुर्घटनाग्रस्त है। फेसबुक एपीआई संस्करण: "Xamarin.Facebook.iOS" संस्करण = "4.13.1"

अद्यतन हटाया अप्रयुक्त कोड।

+0

यदि वे ईवेंट हैंडलर के लिए नहीं हैं तो आपको 'async शून्य' से बहुत सावधान रहना चाहिए। दूसरा, आपको यहां "असफल" बिल्कुल अपलोड करना चाहिए। क्या आपको अपवाद मिलता है? क्या यह चुपचाप असफल हो जाता है? आदि कृपया अपने द्वारा उपयोग किए जा रहे सटीक एफबी एपीआई को पोस्ट करें चाहे वह एक NuGet/घटक/आदि –

+0

है, मैंने आवश्यक जानकारी के साथ अपना प्रश्न अपडेट किया है। – TheDeveloper

+0

यह दिखाने में सहायता के लिए 'mcve' अपलोड करें कि क्या हो रहा है: http://stackoverflow.com/help/mcve दूसरा, क्या आपने अधिक आउटपुट के लिए अपने डिवाइस लॉग की जांच की है? https://kb.xamarin.com/customer/portal/articles/1675684-where-can-i-find-my-version-information-and-logs#debug-logs-for-xamarin-apps –

उत्तर

1

मुझे समाधान मिला।

कोड

<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 फेसबुक iOS SDK का here में उल्लेख द्वारा ठीक मैं सिर्फ 'नेटवर्क अनुरोध करने के लिए श्वेतसूची फेसबुक सर्वर' करने के लिए आवश्यक था।

+0

क्या आप मुझे बता सकते हैं कि मूल पोस्ट में एफबीएसआईएन क्या करता है? यह व्यू कंट्रोलर कैसे प्राप्त करता है :) – LamonteCristo

+0

@LamonteCristo, यह एक यादृच्छिक व्यू कंट्रोलर था ताकि मैं LogInWithReadPermissions() फ़ंक्शन में जा सकूं। यह जरूरी नहीं है, मैंने कोड अपडेट किया। आप नवीनतम कोड देख सकते हैं। – TheDeveloper

संबंधित मुद्दे

 संबंधित मुद्दे