Open stefoid opened 9 months ago
Update on this - I can get the device token. I missed the ...didRecieveToken... in the AppDelegate.m .
However, the issue with getLaunchNotification (iOS only) remains
Hi @stevenmathers thank you for opening this issue, I am currently taking a look at this and will provide an update soon. In the meantime let me know if you have any more context or new information.
HI @stevenmathers following up here - please note that calling getLaunchNotification can return a null result if:
Can you verify if any of these cases may be affecting you?
Additionally in the code snippet you shared, I don't see where you are calling getLaunchNotification()
, if you are could you share the code snippet on how you are calling it?
Hi.
Well, its not a very interesting snippet, but this is called one time only at a specific point in the app after the user has logged in.
startupNotification = await getLaunchNotification();
As I understand it, onNotificationOpened should not be called when the app is started from a terminated state by clicking on a push notification?
@stefoid, can you share where you are calling getLaunchNotification()
?
Its being called after login and syncing of data from the backend, which could take a few seconds. Once the app reaches this point, I call getLaunchNotification for the first time, and once only.
@stefoid, got it. Can you confirm that you're "killing" the app by swiping it away/closing it down? And is the app being relaunched by tapping the notifications that are coming in?
If all this is being done, can you confirm in this scenario that onNotificationOpened()
is being triggered afterwards?
If background mode is enabled, then getLaunchNotification()
may not fire in iOS. If this is the case, then you'd refer to the onNotificationOpened()
.
yes to all the above. The identical JS code works perfectly in Android, as in getLaunchNotification() reliably returns the notification when the app has been launched from tapping the notification (as opposed to bringing it from background to the foreground).
Hey @stefoid
Thanks for getting back to us so quickly. The reason for why the behavior of these APIs different on iOS vs Android is due to how the systems handle background tasks.
With background mode enabled in iOS, when a push notification arrives during a terminated state, it will actually fully wake and start your app in the background (and trigger onNotificationReceivedInBackground
) without launching it to the foreground. Due to this behavior, when you now tap on a notification, your application is actually already awake and therefore it is the onNotificationOpened
which gets triggered.
So getLaunchNotification is N/A to iOS? I suggest documenting the difference in the API if it isnt already (apologies if I missed it)
You're certainly right that we should improve documentation around the specific behavior with the background capabilities enabled. I will add this to our tasks queue.
In the meantime, the combination of getLaunchNotification
and onNotificationOpened
should hopefully satisfy your use cases.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Push Notifications
Amplify Version
v6
Amplify Categories
notifications
Backend
None
Environment information
Describe the bug
These problems are specific to iOS. Android works perfectly as documented
issues 1: when clicking a push notification while the app is terminated, once the app starts up, onNotificationOpened is called. getLaunchNotification returns nothing 2: onTokenReceived is never called
I should note that I am migrating from V5 to V6 following your guide. For V5, I experienced other issues with iOS that prompted me to try out V6. However, onTokenRecieved was working for V5. With just a namechange for V6 and its stopped working.
Expected behavior
getLaunchNotification should be called. onNotificationOpened should not be called
onTokenRecieved should be called
Reproduction steps
apart from the setup code below, both handling permissions (a copy paste of your example permission function) and getLaunchNotification are called later when the app has done its own initialization.
Thats all I can think of.
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response