Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

In iOS Mobile app lost session variable data #238

Closed
ghost opened this issue Dec 8, 2021 · 9 comments
Closed

In iOS Mobile app lost session variable data #238

ghost opened this issue Dec 8, 2021 · 9 comments

Comments

@ghost
Copy link

ghost commented Dec 8, 2021

Hi @Daddoon

Hope you are doing well......

I use the blazor for the web application, Android app and iOS app.
I am facing issue to lost the session variable data in the iOS app when application goes to background or screen lock for 30 min above.
Session variable e.g. key or others details.

What I do to share the session variable from main application to Android and iOS application without lost it if takes long time if mobile sleep.

@Daddoon
Copy link
Owner

Daddoon commented Dec 8, 2021

The Session and Local Storage is cleared at each app initialization. This is by design on the Web part for this project. However you can store your data directly on the native side, and retrieve it at any time when needed with interop.

See: #231
See: Read also this part of the doc: https://github.com/Daddoon/BlazorMobile#communication-between-blazor--native

When your code will reach the native service/interface you will have implemented, use any Storage logic you wich to store your data on the native side. When i used this on some project in the past i used SQLite , but you may store anything differently (A file , a native private store...)

@ghost
Copy link
Author

ghost commented Dec 8, 2021

Hi @Daddoon
I am face issue Webscocket issue when iPhone mobile comes from sleep mode.

The issue message are "blazor mobile not able to connect to native through websocket server execute task" comes when iOS app again use after 30 min or sleep mode.

You provided me above some points, but I always this native approach to share the variables in my application.

@Daddoon
Copy link
Owner

Daddoon commented Dec 8, 2021

Do you have this issue on all iOS devices (if you have many) ?
Does it happen only on a specific versions ?

I don't maintain this project specifically anymore now as you can, i think, migrate easily to .NET MAUI for Blazor on Mobile.
In my opinion the error you are encountering is likely a regression to the iOS version OR if you have updated some NuGet packages references that may behave differently now that could have been used with BlazorMobile.

I think the WebServer does not restart correctly after app restore (but it was working in the past).
I don't have a definitive answer nor the time for fixing this.

But you may try some "hackery" and test on your side.

The idea would be, by yourself, to try to override any logic on your side when the app is restored (returning from sleep mode), and try to Restart manually the webserver.

You would use:

BlazorMobile.Services.WebApplicationFactory.ReloadApplication();

(Source code here if needed: https://github.com/Daddoon/BlazorMobile/blob/ec3d6e4dc290fc0e9347f5a894141c0e891fdfe2/src/BlazorMobile/Services/WebApplicationFactory.cs)

@ghost
Copy link

ghost commented Dec 15, 2021

Hi @Daddoon
Hope you are doing well....

Thank you so much for give me solution. But When I apply.this code on the my App.xml.cs page in the OnResume and OnStart or one of them it not work for the iOS issue. The issue are when the application goes to Sleep or Resume state and we come back to application application loss his native approach variable data.

Please provides me some others solution for that.

Thanks

@Daddoon
Copy link
Owner

Daddoon commented Dec 15, 2021

Have you done some debug to test this behavior ? Do you have anything right or wrong while restarting the webserver ?

@ghost
Copy link

ghost commented Dec 15, 2021

@Daddoon
When I try restart webserver in OnResume() and OnSleep() method then application reload but I loss the native variable data which are store in the application.

But When I kill my application on iOS and click on the icon of app for reopen after this all things working.

I am facing issue when my iPhone goes to sleep mode or resume mode.

@Daddoon
Copy link
Owner

Daddoon commented Dec 15, 2021

What do you mean by "You loss the native variable ?" Where are you storing your data ? Wich API ?
When the app resume are you still able to communicate with native side ?

@ghost
Copy link

ghost commented Dec 16, 2021

Hi @Daddoon
Yes, I lost my "native variable data".
When I resume the app and come into application then I am not able to communicate with the native side data which are store share variable in application.

@Daddoon
Copy link
Owner

Daddoon commented Dec 17, 2021

Sorry, but i have considered that this project is now discontinued. I neither have the time to debug anymore and you have an alternative solution with .NET MAUI that does exactly the same and is supported by Microsoft.

Consider migrating your codebase on this new model. See the README page of this repo.

@Daddoon Daddoon closed this as completed Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant