0

I'm digging around Apple documentation about on-demand resources but I can't find this information..

Is it possible to fetch On-Demand Resources (eg. image, Javascript bundle) from a WKWebView via Javascript?

My intent is to publish some (big) HTML+JS games on Apple servers as On-Demand tagged Resources and then fetch them via Javascript XHR calls or through a Cordova/Phonegap/Ionic plugin.

In this way:

  1. We would not affect the App final bundle size including all the games

  2. Apple would be able to review the games (since it's not externally "injected code" - that is against their guidelines).


In my specific case, I would use the Cordova plugin cordova-plugin-filetransfer to download the tagged on-demand resources and cordova-plugin-file to load and display the downloaded game into the webview.


This is what we need to achieve due to business constraints. Is it feasible?

Gabe
  • 5,997
  • 5
  • 46
  • 92

1 Answers1

0
  1. It looks like it is possible to download a zip file, uncompress it and load it into the Cordova webview using a Cordova only solution (using cordova-plugin-file).
  2. Apple only lets you access those On-Demand Resources using their Native API, they don't have exposed those via an external API.

So, in order to load ODRs in a Cordova App, we would need to create a custom plugin that calls the Native API that takes care of loading the On-Demand Resources (see NSBundleResourceRequest).

Reply found in the Reddit Flutter community:

https://www.reddit.com/r/FlutterDev/comments/ejmf3a/apples_odr_network_via_flutter/

enter image description here

Gabe
  • 5,997
  • 5
  • 46
  • 92
  • Add the same time there is an open PR that would allow you to use a command to add those tags through Cordova: https://github.com/apache/cordova-node-xcode/pull/87. But if that's the case how can we then load them through Cordova, as there does not seem to be a Cordova plugin out there that does it for us? – Gabe Apr 02 '20 at 14:17
  • (update here: https://stackoverflow.com/questions/61094404/able-to-read-downloaded-on-demand-resource-in-ios-simulator-but-not-on-physical) – Gabe Apr 08 '20 at 06:19
  • have you sorted this? I am working at the moment on a cordova app and need the apple's odr? – Nikola Noxious Dimitrov Sep 22 '21 at 14:21
  • ok I've sorted this one as well, by doing a custom plugin – inoxious Sep 27 '21 at 18:26