I would like to navigate to a specific mobile screen when event OnApplicationResume fires. I can define the event and start a Client Action, but how do I programmatically navigate to a specific mobile screen within my app, instead of using a link? I tried to use Javascript flow with $public.Navigation.navigateTo("modulename/screenname"); but without success. I get "There was an error processing your request.


Any suggestion how to do this? Thanks!

Hello Denis,

I'm not sure this is possible, to navigate to a specific screen from the OnApplicationResume.
This system events happens when the application comes from background. 

https://success.outsystems.com/Documentation/10/Reference/Platform_Utilities/System_Events/Mobile/On_Application_Resume

Also, because there is no other event related with the pages themselves being triggered, I don't see how this could be achieved.

Why do you need to navigate away from the current screen when application resume from background?

Cheers,
Eduardo Jauch

Hi Eduardo,

Thanks for your reply!

When my application comes to the foreground, I check to see if documents have been posted in my app's Document folder. These need the user's attention asap, through a screen. So as soon as the resume event triggers, I would like to navigate to a specific screen to present any documents in the Documents/Inbox folder (used by iOS to post intra-app documents).

Hum...

I never used it (I'll do some tests), but maybe using the InApp notification component (from forge) you will be able to achieve what you want.

Cheers,
Eduardo Jauch

Solution

Hi Eduardo,

InApp browser is not usable for me, as the website I am navigating to does not run in it, only in safari and chrome. So I need to navigate to the native safari browser of my phone. I found that I can use Javascript: window.open("yourURL", '_system');

Solution

Hello guys I need this too, because when my application resume I do a security verification and if this fail I force a DoLogout and this works fine, but my client need to navigate to see login page, I want to force a logout and redirecto to login page.

Denis Mulder wrote:

Hi Eduardo,

InApp browser is not usable for me, as the website I am navigating to does not run in it, only in safari and chrome. So I need to navigate to the native safari browser of my phone. I found that I can use Javascript: window.open("yourURL", '_system');

Hello Denis,

Well done :)
It works. Please, mark your answer as the correct, as is the solution for your problem.

Cheers,
Eduardo Jauch

Alexandre Costa wrote:

Hello guys I need this too, because when my application resume I do a security verification and if this fail I force a DoLogout and this works fine, but my client need to navigate to see login page, I want to force a logout and redirecto to login page.

Hello Alexandre,

Following the solution found by Denis, you can add a JavaScript after the DoLogout and use this inside it: 

window.open("Login", '_system');

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Alexandre Costa wrote:

Hello guys I need this too, because when my application resume I do a security verification and if this fail I force a DoLogout and this works fine, but my client need to navigate to see login page, I want to force a logout and redirecto to login page.

Hello Alexandre,

Following the solution found by Denis, you can add a JavaScript after the DoLogout and use this inside it: 

window.open("Login", '_system');

Cheers,
Eduardo Jauch

Hello Eduardo in my case i want to navigate to Login page inside my app, I think this solution is to navigate to a external browser (system default). 


Hello Alexandre,

I tested it :)
It opens a page in your app, it does not open in the browser.

Cheers,
Eduardo Jauch

Hum...

Maybe you are right, in the way that this is cordova, and it will open in the webview or in the inAppBrowser or, like you said, in the native browser...

The only difference is that it does not "seems" to do that... (because you are still "inside" your application)

So, I don´t know...
I'll try a little more :)

Cheers,
Eduardo Jauch

You might want to try and throw a Security Exception after the DoLogout... if you're not logged in it should send you to the login page

Jorge Martins wrote:

You might want to try and throw a Security Exception after the DoLogout... if you're not logged in it should send you to the login page

Hello Jorge,

I tried your approach, but it didn't worked. The OnApplicationResume is called, but raising exception after the DoLogout does nothing. If it worked, would be nice, because you could create an exception and use it to navigate to any page. But it do not work.

And this lead me to think that probably there is a reason why there is no navigate available at this System Client Action...

I manage to navigate to another screen using (I think), using a JavaScript in the OnApplicationReady, where I bind the OnResume action to a function and used a document.location to navigate to the Login page. It works also direct from the OnApplicationResume.

But the application "behavior" become a little "weird"... If you keep sending the application to the back and bringing it forward, it freezes with a black screen...

Cheers,

Eduardo Jauch


Has anyone managed to use $public.Navigation.navigateTo? The sintax bellow does not work:


$public.Navigation.navigateTo('MainFlow.HomeScreen', 3, true);


Alexandre Costa wrote:

Has anyone managed to use $public.Navigation.navigateTo? The sintax bellow does not work:


$public.Navigation.navigateTo('MainFlow.HomeScreen', 3, true);


Yes the function works but the syntax for your screen is incorrect:

$public.Navigation.navigateTo('/ModuleName/ScreenName', 3, true)

But as far as I know you can not do this in the OnApplicationResume.


there is a way to do it?, i need to redirect in OnApplicationResume

Hello all,

I think key is to understand that navigation between screens is only possible from within a screen.

This could be a possible solution:

  • Create a local storage entity "RedirectScreen" with text attribute called "Screen"
  • In OnApplicationReady or OnApplicationResume (depending your use case):
    • Het aggregate on RedirectScreen max record 1
    • Make logic to decide to which screen to go and CreateOrUpdate the current in the aggregate with the screen name
  • Create a new screen called "Redirector" 
    • Make the screen the default screen (right mouse click 'mark as default screen')
    • In the OnInitialize of the screen get the one and only record from RedirectScreen entity
    • use a switch to branch to each screen using a destination
    • Instead of using destinations and a switch you can have a more generic solution using a javascript node with the following javascript
      • $public.Navigation.navigateTo($parameters.screen 3, true)
      • where the $parameters.screen should be filled with following syntax:
        '/ModuleName/ScreenName'

If you don't want to use a local entity, then using a javascript node to add the screen name as a global variable to the window object will also do, just a less low-code solution.

Either you decide in OnApplictionReady or OnApplicationResume what the screen is you want to redirect to or you do it in another event for example on destroy of a screen.

Hope this is clear enough, if not I could make a small example application.

Regards,

Daniel

Hi Daniel,

I am stuck in a similar scenario where I have to use $public.Navigation.navigateTo(ScreenName);

But my question is how to use this JavaScript API function?

When I use this function in my JavaScript code, its giving me error $public is not defined. 
Do I need to use any dependencies to use this ? 

Regards,
Palak Patel

Hi Palek,

This solution is for outsystems mobile application.

As far as I know this works 'out of the box':

Regards,

Daniel