Can you add platform specific code in PhoneGap? - iphone

If I have an application build using PhoneGap is it possible to add to it platform specific code?
For instance, for an iOS version I would like to add Heatma.ps SDK.
Heatma.ps SDK is an iOS specific static library written in Objective-c.

yes you can add as much platform specific code as you want. Phonegap is just for the interaction of the platform specific code and the javascript. Its the plugin mechanism that makes Phonegap what it is. Even if you have a native app, you can add a bit of Phonegap in it by having a page somewhere which is basically a webview and is manipulated by js. Phonegap is what launches and manages the interactions of the js and the native part of the app.

Related

Using native SDK in React Native or Ionic

I intend to develop an app for our site but one of the main worry is that I need to use a 3rd party payment gateway that only provides SDK for android in Java and iOS in Objective-C.
I want to know if it is appropriate to use React-Native or Ionic for the app. I am not sure which of these framework supports integration of native integrated and work flawlessly.
Hope someone with experience can help advise on this.
Thanks.
For react-native you can write your native modules for both android(JAVA) and ios(OBJECTIVE-C). It provides you right to write code in module and then register the module for your further use inside your application.
You can read the complete docs from :-
For android https://facebook.github.io/react-native/docs/native-modules-android.html
and for ios https://facebook.github.io/react-native/docs/native-modules-ios.html

Does Ionic compile the Code to Native?

I've searched some times here but could't find an Answer to this.
Does someone know this and can explain how Ionic handles it?
Does Ionic compile the Code to Native? NO
Ionic is for developing Hybrid apps.
What are Hybrid apps?
Hybrid apps are essentially websites embedded in a mobile app through
what we call a webview. They are developed using HTML5, CSS, and
Javascript, and execute the same code regardless of the platform in
which they run. They can, with tools like PhoneGap and Cordova, use
the native features of a device, like GPS or camera.
What are Native apps?
Native apps are developed in the language required by the platform it
targets, Objective-C or Swift for iOS, Java for Android, etc. The code
written is not shared across platforms and their behavior varies. They
have direct access to all features offered by the platform without any
restriction.
Here is a nice article about it.
Cordova converts the project into a native which has only ONE Page, that is a WebView (WKV WEB View in iOS, etc). And all of the ionic code is run on that webview. Basically an ionic/cordova app is a website which looks like an app!

Can I use third party PhoneGap plugin on a web page using iOS Safari browser?

I am developing an application targeted only for iOS device(for now) using PhoneGap library and HTML5. This application is going to be only a web page accessed through iOS Safari browser. I am going to use certain features like accessing accelerometer, geolocation, contacts etc of iOS device using PhoneGap library.
Will I get access to all these features without installing anything on the device.
I want to understand how does PhoneGap get access to native features
of the device by just using JavaScript only?
I see there are several useful plugins written for PhoneGap library.
Can I simply use those plugins(js files) into my page without
installing anything on the device? E.g PhoneGap ChildBrowser plugin?
Will I get access to all these features without installing anything on the device.
You will have to build as a native ios app and install it to the device.
I want to understand how does PhoneGap get access to native features of the device by just using JavaScript only?
Phonegap provides a Javascript interface to access hardware features which are actually Objective-C functions. If you look at Phonegap source you'll see a lot of Objective-C code. So it's not only Javascript.
I see there are several useful plugins written for PhoneGap library. Can I simply use those plugins(js files) into my page without installing anything on the device? E.g PhoneGap ChildBrowser plugin?
No. They have to be inside an iOS app to be able to work.
It seems like what your after is a way to access the features of an APP only through the browser.
You can access some things using HTML5 e.g.:
Geo location http://html5demos.com/geo
Accelerometer http://menscher.com/teaching/woaa/examples/html5_accelerometer.html
Video Embedding http://www.w3schools.com/html5/html5_video.asp

is it possible to develop hybrid application without using phone gap or quick connect?

I am new to this iPhone development.I would like to create a hybrid application or iPhone.I want to know is it possible to develop hybrid application without using any of the external frameworks or libraries like phonegap or quickconnect or titanium .I just want to know is it possible to create an hybrid application with just HTML file JavaScript files and CSS file and x code?
The idea behind phonegap (can't stress this enough titanium is NOT the same), is that a webview is created in the app and the HTML, CSS, javascript etc. is added to this. Then some other logic allows you to access some of the underlying features like the camera.
So creating a native iPhone application where you create a webview and code the HTML is basically the same idea (as phonegap not titanium, titanium cross complies into native code).

Is Titanium's HTML5 (and JS) really native?

I'm a little confused about this. Titanium is bragging about being able to style with CSS, program with javascript and create with HTML5, whilst making the final product native to the platform. How is this possible? If I'm writing in JS/HTML/CSS then won't they be run within the browser? Making them non-native?
See jhaynie's explanation of how the Titanium Mobile SDK is used to compile to native code. In essence, the Titanium Mobile SDK creates a mapping between their APIs in javascript and the native APIs of the target platform.
Titanium code are written in core JavaScript and code is then converted into native code(i.e. objective c or java) But when you use HTML and CSS into titanium you need to render them into "WebView" a browser without address bar. So in that sense titanium is completely native.
You code a Titanium Mobile app in js using their API that 'bridges' your code to the native API.
You don't use html/css at all unless you want to include a webview with local content.
It's possible you are looking at old documentation. Titanium used to use HTML/CSS/JavaScript for creating applications which did not use native UIs but as of 0.9 is more of a JavaScript abstraction of a generic mobile device. This means you won't be using HTML or CSS to build your app and the process bears little resemblance to building a web app. Other tools like PhoneGap use the web app model in place of a native UI.
That said, you can create a web view (in-app web browser) in Titanium which you can use to show HTML5 content if you so desire. Also, as of Titanium 1.5, you can also use a CSS-style language called JSS to separate your JavaScript application model from your content.
Apple iOS has a "WebView" which is basically a browser window under control of the program. They take your code, plop it in to a WebView and wrap some infrastructure around it, and compile and ship it as a "native" program.