javascript 您如何将 Web 应用程序包装为 iOS 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22035389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 22:15:09  来源:igfitidea点击:

How do you wrap a web app as iOS app

javascriptiosiphoneobjective-cweb-applications

提问by bodokaiser

I have this web appwhich works great on mobile browsers however I would like to allow this app being downloaded as "native app" through the apple app store.

我有这个网络应用程序,它在移动浏览器上运行良好,但是我想允许这个应用程序作为“本机应用程序”通过苹果应用程序商店下载。

My app basically consists out of three files which it serves to the client:

我的应用程序基本上由它提供给客户端的三个文件组成:

  • index.html
  • build.js
  • build.css
  • 索引.html
  • 构建.js
  • 构建.css

My research so far came to the conclusion that it is possible to do this by creating a web view with objective-c which executes the web app. Additionally you may use SDKs like phone gap to use native APIs (which is not required in this case).

到目前为止,我的研究得出的结论是,可以通过使用执行 Web 应用程序的 Objective-c 创建 Web 视图来做到这一点。此外,您可以使用诸如 phone gap 之类的 SDK 来使用本机 API(在这种情况下不需要)。

Unfortunately I do not find a lot information on this by google, so I have following questions:

不幸的是,我没有通过谷歌找到很多关于此的信息,所以我有以下问题:

  1. What is the "keyword" I am looking for (whats the term for "wrapping html app in object-c")?
  2. Do I have to change the urls in my build.js (or can I overwrite current origin)?
  3. Is there anything else I would need to change in build.js?
  4. Are there any problems I should consider?
  1. 我正在寻找的“关键字”是什么(“在 object-c 中包装 html 应用程序”的术语是什么)?
  2. 我是否必须更改 build.js 中的 url(或者我可以覆盖当前来源)?
  3. 在 build.js 中还有什么我需要改变的吗?
  4. 有什么我应该考虑的问题吗?

采纳答案by Segev

Is it possible? Yes. Will apple approve your app? Defiantly not.

是否可以?是的。苹果会批准你的应用吗?绝对不是。

From the App Store Review Guidelines:

来自 App Store 审核指南:

2.12 Apps that are not very useful, are simply web sites bundled as apps, or do not provide any lasting entertainment value may be rejected

2.12 不是很有用的应用程序只是作为应用程序捆绑的网站,或者不提供任何持久的娱乐价值的应用程序可能会被拒绝

  1. web shell, web app
  2. Changing the urls for local path would work.
  3. Depends on how build.js was written.
  4. The above.
  1. 网络外壳,网络应用程序
  2. 更改本地路径的 url 会起作用。
  3. 取决于 build.js 的编写方式。
  4. 以上。

So what can you do?

所以,你可以做什么?

Think how to improve your app with native code and add some functionality to it.

思考如何使用本机代码改进您的应用程序并为其添加一些功能。

Focusing on the native code will help. If you'll submit an app that opens a UIWebViewand that's it apple will 100% reject it.

专注于本机代码会有所帮助。如果您提交一个打开的应用程序,UIWebView那么苹果将 100% 拒绝它。

I wrote an app for my company that wrapped a web app inside a UIWebViewbut had a lot of native code that would sniff the current UIWebViewurl and triggered functions accordingly. (Opened the cam, recorded audio, uploaded stuff to the server) so in the end it was very hybrid.

我为我的公司编写了一个应用程序,该应用程序将一个 Web 应用程序包装在 a 中,UIWebView但有很多本机代码可以嗅探当前UIWebViewurl 并相应地触发函数。(打开摄像头,录制音频,将内容上传到服务器)所以最后它是非常混合的。

Apple rejected it with the claim that the user still sees only a webpage. I had to add a lot of other visible functionality in order for it to get approved.

苹果拒绝了它,声称用户仍然只能看到一个网页。我必须添加许多其他可见的功能才能获得批准。

回答by rptwsthi

Your idea seems like a very general and appealing idea for developers but as far as I know, these sort of applications are not taken very sportingly by apple app reviewer.

您的想法对开发人员来说似乎是一个非常普遍且吸引人的想法,但据我所知,Apple 应用程序评论家并没有非常积极地采用此类应用程序。

When I say these sort, I actually mean application which calls webpages as browser. For these type of calling browser is perfect.

当我说这些时,我实际上是指将网页称为浏览器的应用程序。对于这些类型的调用浏览器是完美的。

Now lets talk about development. If you want to start with development then this is your takeoff place. As you have all your skills with HTML, JS and CSS, you'll rock with this development platform called Phonegap. and the beauty of this platform is you can import same build for other mobile platform as well.

现在让我们谈谈发展。如果您想从开发开始,那么这就是您的起飞点。由于您掌握了 HTML、JS 和 CSS 的所有技能,因此您会在这个名为Phonegap 的开发平台上摇摆不定。这个平台的美妙之处在于您也可以为其他移动平台导入相同的构建。

Looking forward for some worthy applications. Good Luck!

期待一些有价值的应用。祝你好运!

回答by Luke Green

Not sure, but the answers above may be out of date. The new app store guidelinesdo not include the quoted language about "websites bundled as apps." Perhaps Apple has eased up on this issue?

不确定,但上面的答案可能已经过时。 新的应用程序商店指南不包括有关“捆绑为应用程序的网站”的引用语言。或许苹果在这个问题上有所缓和?