Ich benutze Xamarin Facebook sdk für iOS in einem Xamarin-Projekt mit gemeinsamem Code und Formulare Benutzeroberfläche zusammen mit Azure Mobile App-Backend. Ich versuche, Client-Flow-Login mit diesem SDK tun, aber nicht in der Lage. Die App stürzt auf dem Gerät ab, sobald sie gestartet wird. Allerdings, wenn Sie den ähnlichen Ansatz auf der Android-Seite verwenden (mit Xamarin Facebook SDK für Android) funktioniert alles hervorragend. Mein Code basiert auf dem, was Adrian Hall in seinem book vorgeschlagen hat. Es funktioniert gut im Simulator und öffnet die Webansicht für die Anmeldung, schlägt aber auf dem Gerät fehl. Im Folgenden finden Sie den Code in iOS Projekt:Xamarin Facebook sdk für iOS verursacht App Absturz
public class iOSLoginProvider : ILoginProvider
{
public async Task LoginAsync(MobileServiceClient client)
{
var accessToken = await LoginFacebookAsync();
var zumoPayload = new JObject()
{
["access_token"] = accessToken
};
await client.LoginAsync("facebook", zumoPayload);
}
public UIViewController RootView => UIApplication.SharedApplication.KeyWindow.RootViewController;
private TaskCompletionSource<string> fbtcs;
public async Task<string> LoginFacebookAsync()
{
fbtcs = new TaskCompletionSource<string>();
var loginManager = new LoginManager();
loginManager.LogInWithReadPermissions(new[] { "public_profile" }, RootView, LoginTokenHandler);
return await fbtcs.Task;
}
private void LoginTokenHandler(LoginManagerLoginResult loginResult, NSError error)
{
if (loginResult.Token != null)
{
fbtcs.TrySetResult(loginResult.Token.TokenString);
}
else
{
fbtcs.TrySetException(new Exception("Facebook Client Flow Login Failed"));
}
}
}
Ich habe zusätzliche Anforderung von Berechtigungen in info.plist und hat Facebook-Anwendungen als auch die weiße Liste gesetzt. Wenn ich LoginFacebookAsync()
und LoginTokenHandler()
auskommentiere, läuft die App gut. Es startet perfekt, obwohl es sich nicht einloggen kann, weil der Code nicht vollständig ist, aber er startet. Sobald diese Methoden jedoch Code enthalten, kann die App nicht gestartet werden. Ich habe versucht, auf zwei Geräten (iOS 9.3.5 und iOS 10.3.3) und Simulatoren auch zu kompilieren.
aktualisieren Es folgt der Absturzbericht von Geräteprotokoll:
Incident Identifier: 8AEC3E39-8670-4C6B-A87E-9B2C014B1A6E
CrashReporter Key: ce11b8d9b291dbec2269487cc1ef04b41d8b4d35
Hardware Model: iPhone6,1
Process: fbloginios.iOS [646]
Path: /private/var/containers/Bundle/Application/CFE5351F-4DE4-4822-9B42-8C9CE909D905/fbloginios.iOS.app/fbloginios.iOS
Identifier: com.yourcompany.fbloginios
Version: 1.0 (1.0)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.yourcompany.fbloginios [543]
Date/Time: 2017-11-03 08:58:39.0078 -0400
Launch Time: 2017-11-03 08:58:38.5767 -0400
OS Version: iPhone OS 10.3.3 (14G60)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Filtered syslog:
None found
Last Exception Backtrace:
0 CoreFoundation 0x18a332fe0 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x188d94538 objc_exception_throw + 56
2 fbloginios.iOS 0x101596494 0x1000c8000 + 21816468
3 fbloginios.iOS 0x1015cfbd8 0x1000c8000 + 22051800
4 libobjc.A.dylib 0x188d95418 CALLING_SOME_+initialize_METHOD + 24
5 libobjc.A.dylib 0x188d95684 _class_initialize + 612
6 libobjc.A.dylib 0x188d9d4b4 lookUpImpOrForward + 228
7 libobjc.A.dylib 0x188da8478 _objc_msgSend_uncached + 56
8 fbloginios.iOS 0x1000ef02c 0x1000c8000 + 159788
9 fbloginios.iOS 0x1000effd0 0x1000c8000 + 163792
10 fbloginios.iOS 0x1017281a8 0x1000c8000 + 23462312
11 fbloginios.iOS 0x1000f00d4 0x1000c8000 + 164052
12 libdyld.dylib 0x18921d59c start + 4
Was ist die Ausnahme/Stacktrace (native und/oder verwaltet)? – SushiHangover
Das Ausgabeprotokoll in VS wird nicht gestartet. Es sagt nur zwei Dinge: * Starten von 'fbloginios.iOS' auf 'iPhone' ... * Die App wurde beendet. Ich habe die Frage mit dem Gerät Log auf Mac aktualisiert. Vielen Dank. – Nitish
Gerätekonsole: https://developer.xamarin.com/guides/ios/deployment,_testing,_and_metrics/debugging_in_xamarin_ios/#Accessing_the_Console – SushiHangover