Permanently store variable on Mobile App

Permanently store variable on Mobile App

  

Hi.

Is there a way to permanently store a token variable on an Outsystems mobile app? This value will be different for different users. Local storage is not an option as it allows for only entities, whereas I need only a single value.

Thanks!

The simplest way is really using a local entity. Not sure why you stated it's not an option.

Saurav,

Being "local" means the entity data will be stored in the client device. So, every client will have ists own data.

You can simply write a single record "by user" to a local entity and store the token for each user that uses that device.

What's the problem with this approach?

What's the use for this token?

Cheers

Eduardo Jauch

Paulo Ramos wrote:

The simplest way is really using a local entity. Not sure why you stated it's not an option.

Its a single text value, which I retrieve using Javascript. What would I enter as the "Source" of the local storage entity?


Saurav,

I think this link can help you understand how to work with local storage: https://success.outsystems.com/Documentation/10/Developing_an_Application/Use_Data/Using_Local_Storage

It is the same as server storage, basically. You create a local entity and use it the same way you use a server entity. 

Cheers,

Eduardo Jauch

Hi Saurav,

You actually have other alternative here. Since Outsystems mobile apps are single page apps, only the body of the pages change.

If you define a window variable, it should be available cross all screens. On a javascript node you can save the value to window.myVariable. When you want to get that value again, you run a javascript node where you assign window.myVariable to an output parameter and it should do the trick.

Probably you should encapsulate it on client actions like setToken (to assign the value to  the window variable) and getToken (to get the value from javscript to an outsystems variable)

Hope it helps.

Henrique

Hi Henrique, 

But in this case, when the application closes, you looses the value, no?
When I saw the "permanently" in the question, I assumed (my bad) that the requirement was something "cross executions".

Cheers,
Eduardo Jauch

@Eduardo, you're right! I misunderstood the question!

@Saurav, like Eduardo said, my solution only works while the app is running.

Cheers,

Henrique