26
Views
8
Comments
Solved
[Firebase] Use Firebase push notification deeplink when application is running on background
Question
Forge component by Labs
11
Published on 02 Oct 2019
Application Type
Mobile

Hello,

I am using Firebase to send push notifications to users. Push notifications are received as expected. However, deeplinks are not always working. I have 2 scenarios

1. The app is not running (when closing the app, you also kill the app in the multitask screen). The pushnotification is received and when you click, the deeplinks work as expected.

2. The app is running in the background (close the app but do not kill the app in multitask screen). The push notification is received, but when you click, the deeplink is not working. 

We figured out what causes this problem. It lays in the action that handles the push notification. This action is placed in the layout (and layoutblank) webblock. This works when opening the app in scenario 1, because the layout webblock is rendered again. However when in scenario 2, the webblock is not refreshed en thus this notification handler is not notified. I know this because I made a logmessage in that FirebaseCloudMessaging action. I tried to use the onParametersChanged to force the webblock to refresh, but this doesn't work. The OnParametersChanged action is called, but the webblock is not actually refreshed. 

Does anyone have a solution for this problem? We would like to force refresh the webblock to let the action know there is a notification to handle. The other solution is changing the javascript of the notification, but we cannot find the javascript that ensures that the application is opened. Any tips on changing the notification behavior are also welcome.


Thanks in advance,

Tyler

Rank: #1373
Solution

I found the problem! Weirdly, we had some screens where it was working and some screens where it wasn't. That was weird because we used the same layout webblock on both screens. We did some tests and this tests has pointed us to the problem. We had a screen where it was working, we made a new button on a screen which linked to that screen where it was working. The push notification was working when we went to the screen through the working button, but when using the newly made button, the push notifications, again, didn't work. So the journey from button to screen was leading to working or non working push notifications. That is when we decided to change the Module Transition of the button to None (it was previously on slide from left). Now it works!! So appearently the module transition between screens has impact on the push notifications. When changing all module transitions to none, we suddenly had no issues with the push notifications. I will inform OutSystems of this weird behavior

Rank: #68

Hi Tyler,


You can also have your app to run the synchronization when resuming the app and pick up data which has not been processed yet (among which the missing notification).

On another project that's what we did, we saved the timestamp the user last synchronized and when the user resumed the app, the synchronization would run picking the information from that point on (including the information behind the push notification).

This would also solve you the situation of having multiple push notifications. When you click on one, you probably want to get the information from all the others (e.g. on WhatsApp if you have 5 unread messages, when you clicking on one notification, they all are erased and the 5 are processed since you see them on the phone).


Hope it helps.


Regards,
João

Rank: #1373
Solution

I found the problem! Weirdly, we had some screens where it was working and some screens where it wasn't. That was weird because we used the same layout webblock on both screens. We did some tests and this tests has pointed us to the problem. We had a screen where it was working, we made a new button on a screen which linked to that screen where it was working. The push notification was working when we went to the screen through the working button, but when using the newly made button, the push notifications, again, didn't work. So the journey from button to screen was leading to working or non working push notifications. That is when we decided to change the Module Transition of the button to None (it was previously on slide from left). Now it works!! So appearently the module transition between screens has impact on the push notifications. When changing all module transitions to none, we suddenly had no issues with the push notifications. I will inform OutSystems of this weird behavior