Closed JanithaR closed 5 years ago
I've started to notice that 'pushReceived' also isn't firing every time.
Looking at the adb logcat output I see that native events are firing correctly all the time but they are not reflected in JS. Such as this,
05-02 11:49:32.163 10174 10522 I Pushwoosh: [RequestManager]
05-02 11:49:32.163 10174 10522 I Pushwoosh: x
05-02 11:49:32.163 10174 10522 I Pushwoosh: | Pushwoosh request:
05-02 11:49:32.163 10174 10522 I Pushwoosh: | Url: https://....api.pushwoosh.com/json/1.3/messageDeliveryEvent
05-02 11:49:32.163 10174 10522 I Pushwoosh: | Payload: {"request":{"application":"...","hwid":"...","v":"5.13.2","device_type":3,"userId":"...","hash":">z"}}
05-02 11:49:32.163 10174 10522 I Pushwoosh: | Response: {"status_code": 200, "status_message": "OK", "response": null}
05-02 11:49:32.163 10174 10522 I Pushwoosh: x
05-02 11:49:32.163 10174 10522 D Pushwoosh: [RequestManager] messageDeliveryEvent response success
And this is supposed to trigger,
DeviceEventEmitter.addListener('pushReceived', (e) => {
if (__DEV__) console.log(...logHelper.logInfo(TAG, '======='));
if (__DEV__) console.log(...logHelper.logInfo(TAG, 'push received; ', new Date()));
if (__DEV__) console.log(...logHelper.logInfo(TAG, 'data; ', e));
if (__DEV__) console.log(...logHelper.logInfo(TAG, '======='));
});
but not.
Hello @JanithaR,
Is the issue related to Android only or does it affect iOS as well?
pushOpened event is triggered only when a user clicks on a push notification. pushReceived event fires when a push is received in foreground, and also fires when the app is brought to foreground when opening a push.
Could you please confirm that pushOpened event always fires when opening a push notification? Also, by any chance could you please provide us with a reproducer .apk (and .ipa if it affects iOS as well)? You can send it to our support team with a reference to this issue and they will pass it to the SDK team.
Thanks for getting back. Give me a few hours to come up with a more detailed reply when I'm in the office.
Hi, sorry for the long pause.
Yes, this seems to happen for both iOS and Android. What I have observed is very inconsistent. (All instances are triggered by sending a test push notification from the Pushwoosh control panel.)
On Android sometimes the notification in the notification drawer doesn't appear at all, I'm yet to see this happen on iOS. I still haven't figured out what conditions lead up to this weird situation. I must log out, which in turn unregisters from Pushwoosh and the log back in to get it working again.
On Android sometimes 'pushReceived' isn't fired at all either but the notification is there in the notifications drawer. Clicking on the notification would not trigger 'pushOpened' as well.
I'm using react-navigation to navigate the user to a specific screen based on the custom data in the notification. This does work on Android (although with some unexpected behaviour which I'm guessing must be solved by better routing in react-navigation) sometimes but never on iOS which I think is because 'pushOpened' is never fired on iOS. I tried looking at logs but I couldn't see even the native event firing.
I'm not sure how I can provide a separate reproducible application. If you have any suggestions please let me know.
@JanithaR
We have thoroughly tested pushOpened
and pushReceived
callbacks behavior, and it works just as expected on our side - pushOpened is correctly called when a notification is opened both on iOS and Android. pushReceived is fired on Android instantly regardless of whether the app is in foreground, background or if it is closed; on iOS it is fired automatically when the app is in foreground, and it is fired when you open your app by clicking on a notification when the app is in background.
At this point we cannot proceed with the investigation since we cannot reproduce the issue at all.
If you cannot provide us with a reproducer, it would still be really great if you could provide us with device console logs which describe any suspicious behavior.
@wfhm I have resorted to deep linking to resolve the problems I had and it seems to work well but what you say and what I experienced is the polar opposite. I will try to provide a reproducer.
@JanithaR
Sure, we look forward to hearing from you!
Guys, please close this, no need to keep it open.
By implementing deep linking I have resolved the use case where I must direct a user to a specific screen based on the data I receive via a push notification. This works for perfectly fine and I strongly believe that deep linking is the best way to do this.
For future reference, to anyone who would have difficulty implementing this use case and if you're using react-navigation just go on straight and implement deep linking. https://reactnavigation.org/docs/en/deep-linking.html
Edit: I do have another question which I would ask in a separate issue.
im facing exactly the same issues, pushReceived is working as expected, pushOpened not fired on android but fires inconsistently in iOS, we solve the navigation using deep linking as well, but its a workaround and we need the push event data...
we're using "pushwoosh-react-native-plugin": "^5.15.2",
In my opinion, deep linking is the best way to go about this. I found it to be working 100% every time on both iOS and Android, plus, having deep linking enabled in your app gives you other benefits such as letting users open specific content based on URLs.
You can most certainly access your push event data if you're using react-navigation. That's what I have done.
Here's how I extract the data that I want.
router
const HomeStack = createStackNavigator({
...
DetailScreen: {
screen: DetailScreen,
path: 'detail/:data1&:data2'
},
...
}
In the DetailScreen (deep linked) component,
const data1 = navigation.getParam('data1', '');
const data2= navigation.getParam('data2', '');
Test by creating a deep link in the Pushwoosh control panel and sending a push notification with that deep-link to the test devices. (Send Push -> Action -> Choos deep link )
scheme://home/detail/059fe5a7-d9d6-4ec5-88a8-46215103320c&Task
When you have everything working tell the web API team to update the Pushwoosh API /createMessage call with link
And here's a little something extra to ease your life by testing deep linking completely locally,
Android
adb shell am start -W -a android.intent.action.VIEW -d scheme://home/detail/$data1\&$data2 [you_app_package]
iOS
xcrun simctl openurl booted $formatted scheme://home/detail/$data1&$data2
I have a requirement where I must direct the user to a single screen nested in the navigation (react-navigation) based on the userdata I receive over the push notification. I have the following code in my App.js file.
My problem does not lie in the code, it lies where this event not being fired at random and I cannot figure out a reason why.