Skip to content

Commit

Permalink
fix: MAUI eventbinding moved to FinishedLaunching (#3057)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes committed Jan 18, 2024
1 parent d2b4a94 commit feabf09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ If you have conflicts, you can opt-out by adding the following to your `csproj`:
</PropertyGroup>
```

### 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))
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void UseSentry_BindsToApplicationStartupEvent_iOS()

// Act
var lifecycleEventService = app.Services.GetRequiredService<ILifecycleEventService>();
lifecycleEventService.InvokeEvents<iOSLifecycle.WillFinishLaunching>
(nameof(iOSLifecycle.WillFinishLaunching), del =>
lifecycleEventService.InvokeEvents<iOSLifecycle.FinishedLaunching>
(nameof(iOSLifecycle.FinishedLaunching), del =>
del.Invoke(null!, launchOptions));

// Assert
Expand Down

0 comments on commit feabf09

Please sign in to comment.