使用 Phonegap 作为 Rails 3 应用程序的本机容器 [英] Using Phonegap as a native container for a Rails 3 App

查看:29
本文介绍了使用 Phonegap 作为 Rails 3 应用程序的本机容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 PhoneGap 用于 iOS 应用程序,以便我可以利用相机 API.计划是使用 Rails 来管理整个体验.在这一点上,我并不是特别关心性能.如果不是因为需要相机,我会把它设计成一个真正的网络应用程序.

我发现的大多数答案和教程都建议使用 ajax 到后端服务器来呈现前端.在应用程序开发的这一点上,我不确定我想在 JS 中构建这么多视图,并且更喜欢使用 Rails 来呈现视图.我看到了一些非常简短的参考资料,它们使用 PhoneGap 作为容器来真正呈现 Rails 应用程序.抛开性能不谈,这可能吗,我将如何在 PhoneGap 中设置核心 html 文件以让移动应用程序正常运行?

解决方案

我不相信存在这样的容器可以在客户端运行,但可以动态地为 PhoneGap 应用提供服务(即该应用充当 Web 浏览器具有通过 javascript 命令可用的本机功能).

这里是代码,可以准确地展示您所描述的内容.

这里是我做的与演示相关的截屏.

注意:该演示使用的是 out 3.2.1,并且在最新版本的 Xcode 和/或 PhoneGap 中已损坏,但这是可能的,并且这种性质的应用程序在各种应用程序商店中都有效,(Linkedin 以及许多其他人已经这样做.)逻辑是,我只是没有时间用新版本的 Xcode 修复错误,或更新 PhoneGap 代码(进行更新实际上可能会在一个快速工作会话中修复错误).

I'm looking into using PhoneGap for an iOS app so that I can utilize the camera API. The plan is to use Rails to manage the entire experience. At this point, I'm not particularly concerned about performance. If it wasn't for the need for the camera, I would simply design it as a true web app.

Most of the answers and tutorials I have found suggest using ajax to the backend server to render the frontend. At this point in the app development, I'm not sure I want to build so much of the view in JS and would prefer to use Rails to render the views. I have seen a few very brief references to use PhoneGap as a container to literally render the Rails app. Performance aside, is this possible and how would I set up the core html file in PhoneGap to let the mobile app run normally?

解决方案

I do not believe such a container exists to run on the client side but it is possible to dynamically serve a PhoneGap app (i.e. the app acts as a web browser with native functionality available via javascript commands).

Here is code which demonstrate exactly what you are describing.

Here is a screen cast I did associated with demo.

NOTE: The demo is using an out 3.2.1, and is broken as of the latest version Xcode and/or PhoneGap but it is possible, and apps of this nature are valid in the the various app stores, (Linkedin alongwith many others are already doing it.) The logic is there I just haven't had the time to fix the bug with the new version of Xcode, or update the PhoneGap code (doing the update may actually fix the bug in one quick work session).

这篇关于使用 Phonegap 作为 Rails 3 应用程序的本机容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆