0

I want to develop a miminal app for iOS and Android.

Basically, I want to have a widget (or similar micro-app) that displays how many items I have in a list. If I open the widget, it just opens a website, displaying the list, and allowing me to add/remove items. Sounds trivial, right?

What makes it suddenly complex is I want it to function when offline, including add/remove items.

What I am thinking of is to have the widget include a built in minimalist web-server that can serve the (static) content, along with exposing a minimal API that the static page can reference. The static page will have the list of items in indexeddb, will accept new items, delete items, display items etc. When a new item is added it will call the local API to update the number of items, newest item details etc, thereby allowing the widget part of the app to easily display the state. (I do not want to store the items in the app, just the status) When connectivity is regained, the indexeddb is synchronised with the server, performing any relevant additions, deletions etc.
Finally, the API will have a way to receive an updated version of the static page to allow dynamic fixes to the app. Ignore the security concerns, but know I am aware of them and will be treating them seriously.
What I want to know is what would be involved to have an iOS or android app directly expose a web-api able to serve pages and to process some basic GET/PUT/POST requests.

Basically, on installing the app, it should start operating as a server and open https://localhost:8443/main.html (or similar, also maybe http, but tightly limiting to be local only) That page will query https://myserver/getstuff and as the indexeddb is updated, it will call https://localhost:8443/recordstate updating the local state for display in the widget.

The principle behind this is to minimise the device specific code to a basic page server (static page/s) and a very minimalist API (record state, and accept-page-update), along with the widget/micro-display of the state.

I could see a remote page with long-caching working, but I can see that causing a lot of issues that could be avoided by exposing the page directly from localhost.

As you can likely tell, I'm not experienced in this area, so if there is some much better way to do this, please let me know. The key issue is the offline capability and minimising the device-specific code.

asked Sep 23, 2024 at 5:13
1
  • You make a mobile application. You surely can open a cached webpage when the server is offline. And reload it when it is back online. Generally mobiles won't allow you to listen to incoming connections without special privileges. So I don't think it is a good idea. Commented Sep 23, 2024 at 8:21

1 Answer 1

1

Not easily.

The way you can attack this problem is to have two apps. 1 web app, 1 phone app. then you sync the phone database with the web database. either with an off the shelf tool, or via api calls.

Then you can add to both when the phone is off line and have them sync up later.

answered Sep 23, 2024 at 10:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.