[Firebase Mobile] Deeplink from push notification can't be received when the app is in foreground

Forge Component
(22)
Published on 26 May by Patrícia Glória Ferreira
22 votes
Published on 26 May by Patrícia Glória Ferreira

Hey Outsystems dev,

I'm currently developing a mobile app and has deeplink feature using FCM. However I found an issue about the deeplink push notification, when the app is in the foreground or background it failed to deliver the deeplink parameter. After clicking the push notification message, it only redirect to the app home screen not the specific screen that I wanted. It only works when the mobile app is totally closed or never opened.

For the deeplink, I am using this component from the plugin:

And this is how I implemented the logic flow:

I've put this logic in the OnRender event. So yeah just like I stated before, the deeplink is worked only the first time. It only works when the app is closed. After closing the mobile app (but not clear it via task/recent manager) it failed to open the deeplink when the push notification is clicked. When I try the debug mode, the parameter is empty, I wonder why?

Also, is this has something to do with AndroidLaunchMode? Thanks before.

Hello, Aditya Eka Prabowo


I have the same problem in my mobile application. When I send any notification without using OpenNotification, nothing happens. When I use it, it only works when the application is closed. Can anyone help us?

I was having trouble getting anything related to Cloud Messaging working until I re-generated and re-installed the native apps for both iOS and Android.  

Also, I don't think you need to do any of your logic that you have in the OnRender event.  The DeepLink info in the notification should just open your app automatically without that.  That's how it's working for me, anyway.

George Mari wrote:

I was having trouble getting anything related to Cloud Messaging working until I re-generated and re-installed the native apps for both iOS and Android.  

Also, I don't think you need to do any of your logic that you have in the OnRender event.  The DeepLink info in the notification should just open your app automatically without that.  That's how it's working for me, anyway.

 

do you mind to share on how you implemented the deeplink in the push notification? because i've tried to send the parameter manually (via FCM API) with "click_action" attribute but it only redirect to the Homescreen.

On the mobile device, I did not have to add any specific code for the deep link, other than to add a parameter for the record id I wanted to display.

Also, just in case it is not clear, the user has to tap on / open the notification received, in order for the app to open and navigate to the screen indicated in the deep link.  It won't happen without the user opening the notification.

On the server / desktop side of the application, I am using the SendNotificationToTopic server action found in the FirebaseMobile->FirebaseMiddleware module.


Ok, yes, on the mobile device you need to call InitCloudMessaging and SubscribeTopic when you login.  Also, I found that the string used for the Topic needs to have spaces removed or replaced, or it will not work.

The DeepLink local variable above is based on the DeepLink structure again found in the FirebaseMobile->FirebaseMiddleware module:



Then I make my assignments to my local variables.


I use the OutSystems list operators to build the list up - I have 3 parameters, so I call it 3 times.



That's pretty much it.

Hi George, thank you for your further explanation.


Yes, I have followed the method that you are using from the video tutorial. But unfortunately, that didn't work for our mobile app. After clicking the push notification it won't redirect to the specific screen I defined. That's why I'm using OpenNotification function to open the deeplink parameter.

We are using ADAL plugin (office 365) for login authentication. Are you using Outsystems based plugin in your mobile app?

Aditya Eka Prabowo wrote:

Hi George, thank you for your further explanation.


Yes, I have followed the method that you are using from the video tutorial. But unfortunately, that didn't work for our mobile app. After clicking the push notification it won't redirect to the specific screen I defined. That's why I'm using OpenNotification function to open the deeplink parameter.

We are using ADAL plugin (office 365) for login authentication. Are you using Outsystems based plugin in your mobile app?

 

 Yes, I am using several OutSystems based plugins in my mobile app - Camera Plugin and Barcode plugin, among others.

I respectfully submit that your attempt to workaround the problem of not being able to get your deeplink working by using the "OpenNotification" client action is taking you down a blind alley.  I don't believe OpenNotification is meant to be used in the way that you are using it.  

The description I found for this action states: "Checks for unopened notification and retrieves the notification data.  Best if used on a 'HomeRedirect' screen in order to check for notifications and immediately process the deep link."  If your user opens the notification, how would OpenNotification see it anymore, because it is looking for unopened notifications?

Or, maybe I am not understanding how you want this to work.  Your initial post stated that:

1. "...when the app is in the foreground or background it failed to deliver the deeplink parameter."

I am of the opinion that your code in OnRender is interfering with the processing of the deeplink.  It is not necessary to have this type of code or logic if all you want to do is have your app open and navigate to a particular screen, specified in the deeplink, when the user opens the operating system notification.

Build a simple test mobile app in OutSystems with two screens, and send a notification with deeplink to open one or the other screen.  As long as you call InitCloudMessaging somewhere when you login, you shouldn't need any additional code.  Get this working first in this test app, then figure out what's different with your actual app you want to get working.

2. "After clicking the push notification message, it only redirect to the app home screen not the specific screen that I wanted."

This does not make sense to me.  If I purposely provide a screen name that does not exist in my mobile app, when I open the deeplink-enabled notification, I get an error screen stating that the specified screen name does not exist, and a link to re-load the mobile application, which then takes me to the app's home screen.  Is this what you are seeing?  Then the name of the screen you're providing in your deeplink is incorrect.

Maybe you have an older version of the FirebaseMobile plugin installed in your environment?  If so, try upgrading to the latest version.

3. " It only works when the mobile app is totally closed or never opened".

I think this has to do with when and how your OnRender  code is running.  From the OutSystems documentation: "The On Render event handler runs after each time the Screen or Block is rendered, i.e. whenever the Screen or Block is opened (right after the On Ready event handler execution) and after any change of the data of the Screen. "   https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Screen_and_Block_Lifecycle_Events 

I don't think this is what your case calls for, but maybe I am not understanding what you want to happen.  Even so, your use of OpenNotification to try to access notification data from a notification that was just opened seems to me to be the main source of error here.

 

George, I really appreciate your concern and further responses about my case.


Okay, maybe I'll try to answer your response with a bit of explanation.

1. Yes, I've tried to build a sample mobile application for deeplink PN test and it works. The logic method are the exact same as in the tutorial. The only difference is the sample using Outsystems basic login authentication, meanwhile our project is using ADAL Plugin i've mentioned before. So I'm kind of suspecting this.

2. Yes, I've updated the Firebase Mobile plugin version that published in 26 May 2020. Instead I got an issue where in the Android device when receive notification it won't ring any bell (ringtone sounds) anymore. This is another issue I still finding out.

Recently I have tried to republish all the plugin modules, (Firebase Mobile & Middleware) even the extension that included in the plugin. And this time I try to not use the OpenNotification action, just like in the tutorial when it only supposed to work in the home screen background. But it still don't work only stays in the home screen.

Here's on how I implemented the logic:

I leave it empty on the parameter value because the screen I desired don't have any input parameter:

So yeah, that's why I'm using the OpenNotification action as a workaround and unexpectedly it kinda work for the deeplink.. although it still got some issue (only work when the app is not in background/foreground).