newrelic / newrelic-maui-plugin

New Relic Mobile instrumentation for MAUI
Apache License 2.0
9 stars 5 forks source link

NullReferenceException on iOS startup for TrackShellNavigatedEvents #52

Closed InquisitorJax closed 4 weeks ago

InquisitorJax commented 1 month ago

I'm getting a null reference exception when calling CrossNewRelic.Current.TrackShellNavigatedEvents() on iOS

Seems the same thing was reported here: https://forum.newrelic.com/s/hubtopic/aAXPh0000002GOrOAM/mobile-xamarin-issue-track-events

code is called from: AppLifecycle.AddiOS(iOS => iOS.WillFinishLaunching((_,__) => { StartNewRelic(); return false; }));

Your Environment

latest Visual Studio 17.11.5 nuget version 1.1.4

ndesai-newrelic commented 1 month ago

@InquisitorJax where are you calling this ? it should called after you created AppShell for the App.

InquisitorJax commented 4 weeks ago

I just followed the documentation that shows it being added along with the HandleUncaughtException call in the WillFinishLuanching method. I guess this is too soon since the app shell hasn't been assigned yet when this iOS event occurs. I moved it to after AppShell is assigned to MainPage, and that seems to work fine.