在iframe内显示位于www文件夹外部的html文件-在InAppBrowser中工作或解析文本

问题描述 投票:0回答:1

我使用自己构建的自定义插件设法将一些按需资源下载到我的Cordova应用程序中。

[我现在要做的是将它们加载到我的App的iframe中。这可能吗?

如果它们位于(叹气,只读)www文件夹中,我可以简单地指向${cordova.file.applicationDirectory}/www/game.html...但是将它们放在“库”文件夹中(例如,请参见下面的路径)是否可以在iframe中显示它们?('/ var / mobile / Library / OnDemandResources / AssetPacks / 2F2887A0-7B16-4S5D-83C2-1C588A69DA80 / 15533301173473852852 / com.us-company.sports-beta-enterprise.asset-pack-5a105e8b9d10e3329780d62ea2265 .html')

到目前为止,我设法显示它们的唯一方法是:1.使用cdvfile:// localhost路径(见下文)-> InAppBrowser,但我想避免这种情况(cdvfile:// localhost / root / Users / user / Library / Developer / CoreSimulator / Devices / D016D3BC-E9F9-43F2-8EC1-9A471819A9B5 / data / Library / OnDemandResources / AssetPacks / 11129225-E96A-4BEC-9051 -735912378DB0 / 15538308173473832725 / com.us-company-us.sports-beta-enterprise.asset-pack-5a105e8b9d40e1329780d62ea2265d8a.assetpack / flying-block-game.html)2.我自己使用document.createRange + createContextualFragment->解析html文本变得很复杂,难以管理非常规游戏。

任何在App本身的iframe中显示帮助的信息,以便所有请求都通过Ionic引擎并具有我自己的iosapp://自定义方案,而不是cdvfile:// localhost(可能导致CORS拦截器)?

或者,它可以为提供那些ODR下载文件的本地Web服务器使用其他插件工作吗?

[] [] [] [] [] [] [] [] [] []

我设法使用自己构建的自定义插件将一些按需资源下载到我的Cordova应用程序中。我现在需要做的是将它们加载到我的App的iframe中。这可能吗??如果它们是...

我想知道是谁实施了www约束,也许这是我可以修改的东西。在那种情况下,由于我可以依靠自己的自定义方案和在config.xml中设置为首选的应用程序域,因此我可以将单个游戏加载到嵌入ionic-webview服务的应用程序中嵌入的iframe中,并更轻松地解决CORS问题。 >

这是插件代码:
.. so,我想这样的事情应该指向下载的游戏ODR文件夹:

-(NSString *) getStartPath { NSString * wwwPath = [[NSBundle mainBundle] pathForResource:@"www" ofType: nil]; NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; NSString * persistedPath = [userDefaults objectForKey:CDV_SERVER_PATH]; if (![self isDeployDisabled] && ![self isNewBinary] && persistedPath && ![persistedPath isEqualToString:@""]) { NSString *libPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString * cordovaDataDirectory = [libPath stringByAppendingPathComponent:@"NoCloud"]; NSString * snapshots = [cordovaDataDirectory stringByAppendingPathComponent:@"ionic_built_snapshots"]; wwwPath = [snapshots stringByAppendingPathComponent:[persistedPath lastPathComponent]]; } self.basePath = wwwPath; return wwwPath; }

虽然不确定同时运行两个实例是否可行。.

Cordova松弛频道中的更多讨论点:NSString *odrPath= [[NSBundle mainBundle] pathForResource:@"games" ofType: nil];

cordova ionic-framework hybrid-mobile-app on-demand-resources ionic-webview
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.