getInitialNotification
Closed this issue · 5 comments
Hi there. Firebase and other libraries has method like getInitialNotification to find out was the app opened by notification click or not. Is there any methods like that in Pushy? Haven't found anything in documentation. Found something about push and app cold start in iOS source but that's all.
Hi @MrFreemind,
Sure thing.
Please call the Pushy.setNotificationClickListener((data) => {})
method anywhere in your application to listen for when the user clicks your notifications:
Pushy.setNotificationClickListener(async (data) => {
// Display basic alert
alert('Clicked notification: ' + data.message);
// Navigate the user to another page or
// execute other logic on notification click
});
@pushy-me Pushy.setNotificationClickListener((data) => {}) dosent work when app is opened from killed state
Hi @affansk,
If you could please provide the following information about a device experiencing this issue, that would be great:
- Device manufacturer
- Device model name
- Android OS version
its happening in multiple devices. like i am testing in huawei android.
Pushy.setNotificationClickListener((data) => {}) works when app is in foreground or background. but dosent work when i opened from killed state
i am using react navigation getInitialURL() method to handle deeplink.
Thanks for confirming. Can you please try to reproduce the issue on the Pushy React Native Demo project?
- Clone the repository locally:
git clone https://github.com/pushy-me/pushy-demo-react-native.git
- Run
cd pushy-demo-react-native
- Run
npm install
to install the React Native dependencies - Run
npx react-native run-android
to run the app on either an emulator or a connected Android device - Copy the device token from the Xcode console and paste it into the demo page to send yourself a test notification after killing your app
- Tap the notification and observe whether the "Clicked notification: Hello World" alert is displayed
Thanks!