Unity-Technologies / com.unity.mobile.notifications

Mobile Notifications Package
https://docs.unity3d.com/Packages/com.unity.mobile.notifications@2.1/manual/index.html
Other
131 stars 42 forks source link

More reliable open with notification detection #317

Closed aurimasc closed 4 months ago

aurimasc commented 5 months ago

https://jira.unity3d.com/browse/PLAT-8970 Currently retrieving notification on app open is not reliable on iOS. Because of asynchronous notification delivery, when app is launched by tapping a notification, on some devices it takes a frame or two to get the notification. This can cause problems, since one may want to open different scene based on whether app was opened normally or via notification. Until now recommendation to users was to wait for a couple of frames. This PR introuduces to API: iOSNotificationCenter.QueryLastRespondedNotification() which returns an operation that can be returned from coroutine to wait until Unity determines if app was launched via notification or not. We detect if how app was launched by looking into apps launch options. Unified API also got the same counterpart API, on Android it finishes right away.

Testing status: