From 62ffb8cc8a1cbf7eac533bf1823b604415d347e9 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 17 Jan 2024 14:38:33 +0100 Subject: [PATCH 1/4] moved to different callback --- src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs b/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs index f3d621b881..da2a569926 100644 --- a/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs +++ b/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs @@ -79,7 +79,7 @@ private static void RegisterMauiEventsBinder(this MauiAppBuilder builder) #if __IOS__ events.AddiOS(lifecycle => { - lifecycle.WillFinishLaunching((application, launchOptions) => + lifecycle.FinishedLaunching((application, launchOptions) => { // A bit of hackery here, because we can't mock UIKit.UIApplication in tests. var platformApplication = application != null! @@ -100,7 +100,7 @@ private static void RegisterMauiEventsBinder(this MauiAppBuilder builder) platformApplication?.HandleMauiEvents(bind: false); //According to https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate#discussion - //WillTerminate is called: in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason. + //WillTerminate is called: in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason. SentryMauiEventProcessor.InForeground = false; }); From 2f2b20cc9e12d10b4f464b69cd08e0c2d7c59e83 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 17 Jan 2024 14:59:46 +0100 Subject: [PATCH 2/4] Updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4c531d14..25e6ab4000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ If you have conflicts, you can opt-out by adding the following to your `csproj`: ``` +### Fixes + +- Moved the binding to MAUI events for breadcrumb creation from `WillFinishLaunching` to `FinishedLaunching`. This delays the initial instantiation of `app`. ([#3057](https://github.com/getsentry/sentry-dotnet/pull/3057)) + ### Dependencies - Bump Java SDK from v7.1.0 to v7.2.0 ([#3049](https://github.com/getsentry/sentry-dotnet/pull/3049)) From 937f3e47e835433e2398605ceee015ad73e24fa2 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 18 Jan 2024 11:29:51 +0100 Subject: [PATCH 3/4] test --- .../SentryMauiAppBuilderExtensionsTests.Cocoa.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs index 594300c02c..c8a0603c7f 100644 --- a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs +++ b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs @@ -28,7 +28,7 @@ public void UseSentry_BindsToApplicationStartupEvent_iOS() // Act var lifecycleEventService = app.Services.GetRequiredService(); lifecycleEventService.InvokeEvents - (nameof(iOSLifecycle.WillFinishLaunching), del => + (nameof(iOSLifecycle.FinishedLaunching), del => del.Invoke(null!, launchOptions)); // Assert From 0aba6e6c659c2f5a1888c5e9cc3614c55dfc50e6 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 18 Jan 2024 12:50:36 +0100 Subject: [PATCH 4/4] tests #2 --- .../SentryMauiAppBuilderExtensionsTests.Cocoa.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs index c8a0603c7f..716d613185 100644 --- a/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs +++ b/test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.Cocoa.cs @@ -27,7 +27,7 @@ public void UseSentry_BindsToApplicationStartupEvent_iOS() // Act var lifecycleEventService = app.Services.GetRequiredService(); - lifecycleEventService.InvokeEvents + lifecycleEventService.InvokeEvents (nameof(iOSLifecycle.FinishedLaunching), del => del.Invoke(null!, launchOptions));