I am migrating a .NET MAUI iOS authorization movement from one which handles redirect utilizing the now-deprecated customized URL scheme to 1 that employs an Common App Hyperlink verified through a apple-app-site-association file hosted on Firebase.
The callback works. The code is acquired efficiently. The difficulty is that the app crashes upon getting back from the WebAuthenticator
authorization movement. This can be a drawback with iOS solely, not Android which works completely utilizing an Android App Hyperlink served by a assetlinks.json file on the identical server.
Quick query
Have you ever gotten this to work? In that case skip all of the laborious particulars and stroll me via it! In any other case, right here is…
What I’ve tried
- Confirm the Common App Hyperlink utilizing the Developer settings on iPhone.
- With the app debugger connected, inject the URL in Safari from a particular “redirect check” web page on our server. Confirm {that a} breakpoint in
ContinueUserActivity
is hit. Confirm that the app doesn’t crash when the Common App Hyperlink is exercised on this method.
- Setting a breakpoint to examine the returned authorization code. Then returning instantly to keep away from any chance of different exceptions.
buttonLogin.Clicked += async (sender, e) =>
{
var clientId = "123456789012-1ok9rauo969og7aljrnri1gesrr7l1b3.apps.googleusercontent.com";
var redirectUrl = "https://myfirebasedomain.com/auth";
var scopes = "profilepercent20openidpercent20email";
var authUrl = $"https://accounts.google.com/o/oauth2/auth?client_id={clientId}&redirect_uri={redirectUrl}&immediate=consent&response_type=code&scope={scopes}&access_type=offline";
Uri authUri = new Uri(authUrl);
Uri callbackUri = new Uri(redirectUrl);
WebAuthenticatorResult end result;
attempt
{
end result = await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions
{
Url = authUri,
CallbackUrl = callbackUri,
PrefersEphemeralWebBrowserSession = true
});
}
catch (TaskCanceledException)
{
// 'Not' an error. The person merely cancelled this op.
return;
}
catch (Exception ex)
{
Debug.Fail(ex.Message);
return;
}
// Change the authorization code for an entry token
var payload = new
{
code = end result.Properties["code"],
redirectUri = redirectUrl,
clientId = clientId,
key = "internet",
};
var jsonPayload = JsonConvert.SerializeObject(payload, Formatting.Indented);
var content material = new StringContent(jsonPayload, Encoding.UTF8, "software/json");
utilizing var httpClient = new HttpClient();
HttpResponseMessage? response = null;
string? error = null;
attempt
{
// Change token utilizing secret saved on server.
// We're unable to try this. The async publish causes this
// methodology to return, and when it does, the app crashes.
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
if (response != null)
{
error = await response.Content material.ReadAsStringAsync();
}
Debug.Fail(error ?? "null");
}
};
Worth of jsonPayload
signifies success
{
"code": "4/0AanRRrte8fELNx0CyzgsPzrGCo46TLvkp_JhQaG0ao8DMmVLySwN4_8KIfAXNiouGAqkrQ",
"redirectUri": "https://myfirebasedomain.com/auth",
"clientId": "123456789012-1ok9rauo969og7aljrnri1gesrr7l1b3.apps.googleusercontent.com",
"key": "internet"
}
- Going up a stage to wrap the
ContinueUserActivity
for exceptions. I can set a breakpoint onreturn end result
. The crash happens if this methodology is allowed to run from that time.
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
public override bool ContinueUserActivity(UIApplication software, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
bool end result = false;
attempt
{
// Calling the BC is what causes the AuthenticateAsync process to finish.
end result = base.ContinueUserActivity(software, userActivity, completionHandler);
}
catch (Exception)
{
// NO exception being caught right here.
}
return end result;
}
}
My query:
AFAIK I am doing every thing proper, however can anybody spot any motive for the crash? I am inclined to log it as a bug towards WebAuthenticator
for iOS, however earlier than I do something dumb please “examine my work!”
Crash Log (iPhone 11 bodily gadget)
Loaded meeting: Anonymously Hosted DynamicMethods Meeting [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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_get_original_working_directory_path
0x101842cdc - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1c72e0de8 - /usr/lib/dyld :
=================================================================
Fundamental Fault Handle Reporting
=================================================================
Reminiscence round 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 enter 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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d1d0c - /personal/var/containers/Bundle/Software/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: Received a SIGSEGV whereas executing native code. This normally signifies
a deadly error within the mono runtime or one of many native libraries
utilized by your software.
=================================================================
=================================================================
Native stacktrace:
=================================================================
INFO: 0x101804b64 - /personal/var/containers/Bundle/Software/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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_get_original_working_directory_path
0x101842cdc - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1c72e0de8 - /usr/lib/dyld :
Exiting early on account of 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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_UIApplicationMain
0x101815404 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101813d04 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101808714 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1018062ac - /personal/var/containers/Bundle/Software/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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x10177c548 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101782844 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017da4a0 - /personal/var/containers/Bundle/Software/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:Fundamental <0x00152>
at GoogleDriveLocalSyncProxy.Maui.TestProject.Program:Fundamental <0x0002c>
at :runtime_invoke_direct_void_string[] <0x0007e>
at <0x00000>
=================================================================
=================================================================
Native Crash Reporting
=================================================================
Received a SIGSEGV whereas executing native code. This normally signifies
a deadly error within the mono runtime or one of many native libraries
utilized by your software.
=================================================================
An error has occurred within the native fault reporting. Some diagnostic info shall be unavailable.
INFO:
=================================================================
Native stacktrace:
=================================================================
0x101804b64 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017efa50 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d1d0c - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
INFO: ...
=================================================================
Managed Stacktrace:
=================================================================
at <0xffffffff>
at UIKit.UIApplication:xamarin_UIApplicationMain <0x000b8>
at UIKit.UIApplication:UIApplicationMain <0x0006e>
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: ..@...}[email protected]
INFO: 40 f9 02 82 7d 92 51 10 40 f9 31 03 10 36
INFO: 0x1018062ac - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017d4e84 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x10177c548 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101782844 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x1017da4a0 - /personal/var/containers/Bundle/Software/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 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : xamarin_UIApplicationMain
0x101815404 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101813d04 - /personal/var/containers/Bundle/Software/0D3ED65C-DDCD-40D0-A24A-BE6EDA007591/IVSoftware.Maui.EchoesSyncProxy.app/IVSoftware.Maui.EchoesSyncProxy : AppleCryptoNative_X509ImportCollection
0x101808714 - /personal/var/containers/Bundle/Software/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 distant debugger (TCP)
INFO: Closing debug connection from gadget (USB)
The app has been terminated.
INFO: Disposing enter and output streams...
INFO: Disposing console and debugger streams...
ERROR: An error occurred whereas writing to the debug stream. Particulars: ObjectDisposed_Generic
ObjectDisposed_ObjectName_Name, UsbStream