When I try tapping the notification when the app is on the background and redirect to BeachView I get this error:
I used the code provided in the book:
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse
) async {
if response.notification.request.content.userInfo["beach"] != nil {
// In a real app you'd likely pull a URL from the beach data
// and use that image.
await MainActor.run {
isBeachViewActive = true
}
}
}
The only way that I got it working is by putting that MainActor call inside a Task. Any idea why is this happening?