Writing apps for Apple platforms with Javascript - javascript

Does Apple allow iOS and Mac apps to use Javascript? Can someone give me examples of how to use it and the advantages and disadvantages?

If you're looking for a less techy solution, you could also use AppFurnace ( http://www.appfurnace.com ) to create JavaScript & HTML5 apps, packaged as native apps for iPhone and Android. We use PhoneGap (mentioned above), with an added drag-and-drop interface, enabling you to make your own apps.

You can use phonegap as a javascript, html and css wrapper in your ios app if you want to create a native app using html and javascript.

There's NimbleKit which allows you to make native apps using HTML and Javascript. Otherwise you can use a UIWebview which you can execute Javascript in. Look at the UIWebView documentation for more info.

There are tools to code your app in javascript and compile it into native code.
But if you want your app to load javascript code at runtime and run it, then see this for more details.

Related

Can Titanium code runs in browsers?

I understand that not all the code and functionality are available. However, I am currently in the planing of a new project and there are no document to be found on this aspect.
I want to know once I code in Titanium, is it possible to make a web version for mobile without the application with limited feature and the same code base? (something like touch.facebook.com vs Facebook app)
Thank you very much
Of course, Titanium could do that since it also supports MobileWeb. Titanium features:
Develop native applications for iOS, Android, BlackBerry, Windows, and
mobile web through a single code base.
With their Titanium Studio, you can easily build and package your app for MobileWeb.
But there are a lot of things to consider on developing titanium apps. Here are the few things I've learned along the way:
Don't use ImageView. Use View with backgroundImage. If it's an icon, you can make a font for your app. See how to create an icon font using IcoMoon.
Memory management
Never use borderRadius, borderWidth, borderColor in components within components, as for example a ScrollableView.
Minimize calling Ti.Platform.[property_name]. Example: instead of always calling Ti.Platform.osname to your controllers, you could have put it on you commonjs var osname = Ti.Platform.osname, then exports.getPlatformName = function() { return osname; };
Here are some few references:
http://developer.appcelerator.com/question/152656/tips-and-tricks-for-memory-management
http://developer.appcelerator.com/question/116867/this-is-a-solution-to-your-memory-woes#answer-203729
http://www.tidev.io/category/howtos/
Titanium SDK supports iOS, Android, BlackBerry, Tizen and HTML5 platforms. You can read more about that in their documentation. You can limit features in HTML5 app in a code with simple if() and reuse most of your codebase.
You can create a web version of the application if you include Mobile Web in the target platforms, when you create the project.
To deploy it on the browser, run the application as Mobile Web.
You may refer the following links for more details.
Getting Started with Mobile Web
Mobile Web Platform Overview
Mobile Web Limitations

Is it possible to implement HTML5 (I plan to use WebRTC)as a WebView within a native Android application?

I am thinking about developing a android application to make a WebRTC call. Unfortunately the native WebView in android does not support such feature. I tried XDK with CrossWalk and it works with WebRTC well, but the problem is that it is a pure HTML, Javascript application. I suppose the capability of HTML5 application in android would be a problem? (Notification, service, communication with database). So what I am thinking is that maybe I can build a hybrid application with the framework of a native application and a WebView with it? Thanks in advance, that would help me a lot.
Yes, it is possible. I build this HTML5 , https://www.noupei.com/. Its fully HTML5, build using jQuery and jQuery Mobile. One of my college easily transpose it using a webview for android, https://play.google.com/store/apps/details?id=com.knowledge7.android.noupei
BUT
It is also possible to completely develop your whole application using HTML5, and then package it with something like phonegap, the advantage you have is that using something like phonegap allows you to access the native features of the Android Device.
For HTML5 technologies like Bootstrap that allows you to make very good mobile interfaces are fully mobile responsive. It is possible to make very beautiful and attractive interfaces as well as you also have very good javascript frameworks like AngularJS.

Can we use phonegap javascript library with a regular internet site?

If i develope a regular Website using the phongap.js library, Will it still works on mobiles
(with access to goelocation,media,device,events etc...) Without turning it into an application?
(without using the SDKs or phonegap build)?
No, phonegap.js has hooks to the native systems. It has to have the native objective-c and Java files in order to work and access those features.
You can however use HTML5 geolocation for geo, but other than that you're very limited.
Unfortunately no. Phonegap API's only interface with phones and mobile devices when running within a wrapper which provides those extra features. The JavaScript calls can not function without the platform-specific libraries there to support them.
Further reading:
http://groups.google.com/group/phonegap/browse_thread/thread/cde8e4735dd6da9d
http://paulparisi.com.au/2011/09/26/adventures-in-reverse-engineering-a-phonegap-app/
Again, no. The PhoneGap library must be compiled, something which is not offered via web applications served directly from urls.
You'll often find whilst debugging an error we have been fighting with for quite sometime, which is "com is not defined."

Is it possible to deploy an app that I coded for Android to iOS?

I'm using Eclipse to build my Android app using XML and JavaScript. Is it possible to deploy it to the App store without rewriting all the code?
If you have coded your app to be substantially made up of a webview, then you can transfer all that part of the code over by several methods - the one that I think would be easiest would be phonegap.
In the future, you can think about using Titanium Studio which allows you to code in Javascript (and a tiny bit of XML for configuration) and compiles to native code for both Android and iOS - so has native performance.
If you written your app in something like Sencha or PhoneGap - then you can run that code on every platform these frameworks support. But it's in Java (not JavaScript), then there's no way run it on iOS I'm afraid.

Javascript app in Android

I am new to Android programming, and looking for some general knowledge. I am considering writing logic of my application in javascript so that the same code could be executed in a webapp and in a desktop application. Would it be possible to also have it working on Android? I know that:
SL4A is marked as alpha-quality, and user would need to install it to make such an app work. Still it provides access to Android API. SL4A scripts also cannot go to Android Market, as far as I know.
A simple webapp doesn't have access to most Android API.
Would it be possible to write a simple Java app that would embed an HTML widget with javascript code and provide some wrapper to access necessary API?
I am not looking for a fully portable thing--I intend to adapt UI to each environment manually. I just would like to have the internal logic common to all ports.
PhoneGap allows you to write an HTML-based app that not only works with Android, but also iPhone, Windows Phone 7, WebOS and more. The API is standardized, so you can use the same page on all the platforms.
There's support for the most common native features on most platforms. (Here's a chart of the features supported on each platform) In addition, if you find that there's a feature you cannot replicate using only their API, you can write a plugin in the native platform language (so, for Android that'd be Java), and then call that plugin from your HTML/Javascript-page.
If you want to use javascript and access the native api then you should try Appcelerator.com. Those people are providing this.
There is Rhino, which is a Javascript engine written in Java. It works in Android, and it is used by Appcelerator's Titanium mentioned in another answer here.
User interface and Android-specific API can then be written and wrapped in Java, then called by the logic code written in Javascript and run by Rhino.
Consider GWT, a Java to javaScript compiler. You can write your logic and a lot of other code in plain old Java(There are a few things(e.g. reflection) that you can't do like reflection but you wouldn't be able to do it in javaScipt either) Applications like Google inbox are using GWT to reuse a lot of their code in javaScript. They don't just reuse logic either. You can reuse dependency injection, your architecture, AJAX calls and more. Also, GWT is faster than javaScript in both the browser and the JVM. The biggest problem you might have with GWT is that it's more complicated javaScript. Regular Java is already more complicated. Making it work on both the JVM and browser can only make things more complicated. Also, GWT was designed from the ground up for extremely complciated web apps.

Categories

Resources