Apps loading hex files #645
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently WIP but writing all this down so it's not lost in the new year...
Supported approaches to loading hex files on Android and iOS
Sharing
In both android and iOS, sharing is handled by a separate activity / share target, which is tied to the lifecycle of the calling app. It needs to transfer the data it needs to its own files area (file access control is not shared outside of the share handler), then launch the main CreateAI Capacitor App. The share target activity will cease to exist once the share flow is completed, and the main CreateAI app has a different process lifecycle.
Android
On android, ShareReceiverActivity is opened whenever a hex file is shared, copies the file into the app's area, and it launches the MainAcitivity using a private intent containing the local URL.
Note that Android share operations often mangle the file information, so we cannot filter for files named ".hex" in a useful way. Instead, this uses a combination of
application/octet-streammime type, and a hope that the MakeCode importer will correctly bounce erroneous files. It seems to.iOS
The CreateAI Share Target is opened whenever someone hits the "Post" button, and it also takes a copy of the file, which it stores in an App Group. The path to the file in the app group is then used as a local private URL with which the main app is launched.
TODO: I span up a debug App Group locally, but the foundation is going to need to create one under its own account and correctly label it in the plist. (See Note below)
TODO: needs to filter on file extensions.
Note for next year
Alex needs adding to the Foundation's iOS developer team, so they can use the
org.microbit.createaiapp ID and also create an app group. I've been hacking in a development App Group IDs using my own account for now, but this is not available to others on the team.