App-Absturz nur auf iOS nach erfolgreichem WebAuthenticator-Rückruf über Universal App LinkC#

Ein Treffpunkt für C#-Programmierer
Guest
 App-Absturz nur auf iOS nach erfolgreichem WebAuthenticator-Rückruf über Universal App Link

Post by Guest »

Ich migriere einen .NET MAUI iOS-Autorisierungsfluss von einem, der die Weiterleitung mithilfe des inzwischen veralteten benutzerdefinierten URL-Schemas verarbeitet, zu einem, der einen universellen App-Link verwendet, der über eine auf Firebase gehostete Apple-App-Site-Association-Datei überprüft wird.
Der Rückruf funktioniert. Der Code wurde erfolgreich empfangen. Das Problem besteht darin, dass die App abstürzt, wenn sie vom WebAuthenticator-Autorisierungsfluss zurückkehrt. Dies ist nur ein Problem mit iOS, nicht mit Android, das perfekt funktioniert, wenn ein Android-App-Link verwendet wird, der von einer assetlinks.json-Datei auf demselben Server bereitgestellt wird.
Kurze Frage
Haben Sie das hinbekommen? In diesem Fall überspringen Sie alle mühsamen Details und führen Sie mich durch! Ansonsten ist hier...

Was ich versucht habe

  • Überprüfen den Universal App Link mithilfe der Entwicklereinstellungen auf dem iPhone.
[img]https://i.sstatic .net/yraAaQp0.png[/img]

  • Fügen Sie mit angeschlossenem App-Debugger die URL in Safari von einer speziellen „Redirect-Test“-Seite auf unserem Server ein. Stellen Sie sicher, dass ein Haltepunkt in ContinueUserActivity erreicht wird. Stellen Sie sicher, dass die App nicht abstürzt, wenn der Universal App Link auf diese Weise ausgeübt wird.
< ol start="3">
[*]Festlegen eines Haltepunkts zur Überprüfung des zurückgegebenen Autorisierungscodes. Dann kehren Sie sofort zurück, um die Möglichkeit weiterer Ausnahmen zu vermeiden.

Code: Select all

buttonLogin.Clicked += async (sender, e) =>
{
var clientId = "123456789012-1ok9rauo969og7aljrnri1gesrr7l1b3.apps.googleusercontent.com";
var redirectUrl = "https://myfirebasedomain.com/auth";
var scopes = "profile%20openid%20email";
var authUrl = $"https://accounts.google.com/o/oauth2/auth?client_id={clientId}&redirect_uri={redirectUrl}&prompt=consent&response_type=code&scope={scopes}&access_type=offline";

Uri authUri = new Uri(authUrl);
Uri callbackUri = new Uri(redirectUrl);

WebAuthenticatorResult result;
try
{
result = await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions
{
Url = authUri,
CallbackUrl = callbackUri,
PrefersEphemeralWebBrowserSession = true
});
}
catch (TaskCanceledException)
{
// 'Not' an error. The user simply cancelled this op.
return;
}
catch (Exception ex)
{
Debug.Fail(ex.Message);
return;
}

// Exchange the authorization code for an access token

var payload = new
{
code = result.Properties["code"],
redirectUri = redirectUrl,
clientId = clientId,
key = "web",
};
var jsonPayload = JsonConvert.SerializeObject(payload, Formatting.Indented);
var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
using var httpClient = new HttpClient();
HttpResponseMessage? response = null;
string? error = null;

try
{
// Exchange token using secret stored on server.

// We are unable to attempt this. The async post causes this
// method to return, and when it does, the app crashes.
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
if (response != null)
{
error = await response.Content.ReadAsStringAsync();
}
Debug.Fail(error ?? "null");
}
};
Der Wert von jsonPayload zeigt den Erfolg an

Code: Select all

{
"code": "4/0AanRRrte8fELNx0CyzgsPzrGCo46TLvkp_JhQaG0ao8DMmVLySwN4_8KIfAXNiouGAqkrQ",
"redirectUri": "https://myfirebasedomain.com/auth",
"clientId": "123456789012-1ok9rauo969og7aljrnri1gesrr7l1b3.apps.googleusercontent.com",
"key": "web"
}
  • Eine Ebene nach oben gehen, um die ContinueUserActivity für Ausnahmen einzuschließen. Ich kann einen Haltepunkt für das Rückgabeergebnis festlegen. Der Absturz tritt auf, wenn diese Methode ab diesem Punkt ausgeführt werden darf.

Code: Select all

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() =>  MauiProgram.CreateMauiApp();
public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
bool result = false;
try
{
// Calling the BC is what causes the AuthenticateAsync task to complete.
result = base.ContinueUserActivity(application, userActivity, completionHandler);
}
catch (Exception)
{
// NO exception being caught here.
}
return result;
}
}
Meine Frage:
AFAIK Ich mache alles richtig, aber kann irgendjemand einen Grund für den Absturz erkennen? ? Ich neige dazu, es als Fehler gegen WebAuthenticator für iOS zu protokollieren, aber bevor ich etwas Dummes mache, „überprüfen Sie bitte meine Arbeit!“

Absturzprotokoll (physisches iPhone 11-Gerät)

Code: Select all

Loaded assembly: Anonymously Hosted DynamicMethods Assembly [External]
INFO:   0x1a3be2db0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a390977c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__

INFO:   0x1a3c6677c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO: 014e7888 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_get_original_working_directory_path
0x101842cdc - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1c72e0de8 - /usr/lib/dyld : 

=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x19e5d634c):0x19e5d633c  21 20 37 91 30 06 00 14 00 00 00 ea 6d ff ff 54  ! 7.0.......m..T
0x19e5d634c  10 00
INFO: 0x19e5d635c  30 04 00 36 11
INFO:   0x1a3abee00 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3c02410 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3908434 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3886350 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO: Disposing input and output streams...
INFO:   0x1a10d5bbc - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : 
0x1a10d21b0 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : 
0x1a1124274 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific

INFO:   0x1a38863c0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a2c47008 - /System/Library/Frameworks/QuartzCore.framework/QuartzCore : 

INFO:   0x1a3908434 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3c02410 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3c02790 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3886350 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3909718 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3ac1944 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1c4e37488 - /System/Library/Frameworks/SafariServices.framework/SafariServices : 

INFO:   0x1a3abee00 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1017efa50 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d1d0c - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x22bba8ca8 - /usr/lib/system/libsystem_platform.dylib : 

INFO:
=================================================================
Native Crash Reporting
=================================================================

INFO: Got a SIGSEGV while executing native code.  This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

=================================================================
Native stacktrace:
=================================================================

INFO:   0x101804b64 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection

INFO:   0x1a8e0bfa8 - /usr/lib/system/libdispatch.dylib : 
0x1a8e1aa34 - /usr/lib/system/libdispatch.dylib : 

INFO:   0x1a8e1a64c - /usr/lib/system/libdispatch.dylib : _dispatch_main_queue_callback_4CF

INFO:   0x1014e7888 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_get_original_working_directory_path
0x101842cdc - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1c72e0de8 - /usr/lib/dyld : 

Exiting early due to double fault.

INFO:   0x1a1124274 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
0x1ee26d4c0 - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
0x1a3c6677c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a388ce64 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
0x1014bc5f4 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_UIApplicationMain
0x101815404 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101813d04 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101808714 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1018062ac - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncP
INFO:   0x1a2c47008 - /System/Library/Frameworks/QuartzCore.framework/QuartzCore : 
0x1a8e0bfa8 - /usr/lib/system/libdispatch.dylib : 
0x1a8e1aa34 - /usr/lib/system/libdispatch.dylib : 
0x1a8e1a64c - /usr/lib/system/libdispatch.dylib : _dispatch_main_queue_callback_4CF
0x1a10d5bbc - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : 
0x1a10d21b0 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : 

INFO:   0x1a38863c0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a390977c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__

INFO:   0x1a3909718 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO: roxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d4e84 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x10177c548 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101782844 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017da4a0 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection

INFO:   0x1a3c02790 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:   0x1a3ac1944 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:    0x1a3be2db0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : 

INFO:     at UIKit.UIApplication:Main 
at GoogleDriveLocalSyncProxy.Maui.TestProject.Program:Main 
at :runtime_invoke_direct_void_string[] 
at  
=================================================================

=================================================================
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

An error has occurred in the native fault reporting. Some diagnostic information will be unavailable.

INFO:
=================================================================
Native stacktrace:
=================================================================
0x101804b64 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017efa50 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d1d0c - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection

INFO: ...

=================================================================
Managed Stacktrace:
=================================================================
at  
at UIKit.UIApplication:xamarin_UIApplicationMain 
at UIKit.UIApplication:UIApplicationMain 

INFO:   0x22bba8ca8 - /usr/lib/system/libsystem_platform.dylib : 
0x1c4e37488 - /System/Library/Frameworks/SafariServices.framework/SafariServices : 

INFO:  `..T.  .......
INFO: fe 77 d3 91 fe ff b4 3f 06 00 f1  0..6..w.....?...
INFO:  ..@...}.Q.@.1..6

INFO: 40 f9 02 82 7d 92 51 10 40 f9 31 03 10 36
INFO:   0x1018062ac - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d4e84 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x10177c548 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101782844 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017da4a0 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1
INFO:   0x1a388ce64 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
0x1014bc5f4 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_UIApplicationMain
0x101815404 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101813d04 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101808714 - /private/var/containers/Bundle/Application/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection

INFO:   0x1ee26d4c0 - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal

INFO:
0x19e5d636c  60 02 00 54 11 20 e0 d2 11 02 11 cb e1 03 10 aa
INFO: Closing debug connection from remote debugger (TCP)
INFO: Closing debug connection from device (USB)
The app has been terminated.
INFO: Disposing input and output streams...
INFO: Disposing console and debugger streams...
ERROR: An error occurred while writing to the debug stream. Details: ObjectDisposed_Generic
ObjectDisposed_ObjectName_Name, UsbStream

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post