0

We are about to make a hybrid app of sorts of our current Web based app to enable offline usage along with some more usage of native app functionality in mobile devices. The app we are developing is today running on .net5 (soon to be 6) under iis and we have decided to use .net maui and the new blazor webview as the basis for our mobile device app. This way we can move the server engine code to the client (it´s fairly light weight), actually reuse most if not all of our current javascript code and css and keep developing the two platforms (web and mobile app) in parallell.

The one issue we are facing right now is that our app can change at any time. Using a web GUI our administrators can alter the contents of the app, including text, images, sound files and also other content. Our idea was to simply download the new/changed content and store on device and then the webview should be able to use it offline as well. Text content is easy but we can´t quite figure out how to do this for images and audio/video though. It seems the blazor webview is locked into only displaying content from the wwwroot assets folder, which would be fine except we can´t really add content to that folder after deploying the app (as far as we have figured out at least). So my question is what is the best way to handle something like this? Ideally I would like to be able to change where the webview is looking for content to a directory that we can write to (we are able to write files in some kind of file system, just not the assets/resources which are part of the app package). One solution we could use (for images at least) is to set the source to base64encodings of the images, that way we can load the encodings from disk but it seems kind of hackish and also not really an option for sound and video.

So what would be the best way forward here?

Base64encoded images and audio/video only when online? Preload the images (and possibly videos) in the webview (but hidden) and rely on the webview to cache them for offline viewing? (can we force offline caching of them?) Is it possible to make the webview look into a folder we can write to?

If anything is unclear the comment and I´ll be glad to try and explain it better...

2
  • 1
    Sound like most #MAUI questions are left unanswered, not sure how serious Microsoft is with this new framework Commented Jan 26, 2022 at 17:45
  • Did you ever get MAUI up and running for your app? Looks like Microsoft went full force with MAUI with the new updates. Commented Nov 10, 2022 at 14:44

1 Answer 1

1

There are couple of options here.

  1. Create Blazor WebAssembly PWA Project.
  • This would allow you to run offline, with additional benefit of communicating with your backend API if needed.

  • Since this runs inside/under browser of the device, you have access to few Sensors like Location (GPS), camera etc. via HTML 5 if that is all you need. Any changes that you make to your front-end or backend will become available on next restart of App by the user once deployed on your webserver. The user will have same user experience as he would have on web browser.

  • Your users can create icon on the iPhone or Android much like a AppStore App, but to do this they will have to open your site once in safari or chrome on their mobile device.

  1. Create WebView (instead of BlzorwebView) based Device Project and point the WebView to your Website.
  • This would allow you to publish your App to AppStore or PlayStore.
  • This kind of app would immediately show any changes that you make to your appp as soon as you publish it to your webserver.
  • You will have to test Sensor access for each platform as it is very Dicy. I have heard that Apple is bit strict on allowing app to be published on their store when it only has WebView and nothing else, nevertheless this should be quick to find out since you don't have to code anything, just package and publish a shell app.
  1. Creating Blazor Hybrid. In this model your code will have full access to native sensors, but for any changes you will have to re-deploy. you can have code that can make API call, but using that to update your app would be unsupported hacky way of doing it, which is not recommended. If your need is to access sensors not supported by HTML5, blazor Hybrid is the way to go.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.