How to set up Wikitude Phonegap plugin in iOS mobile app project? - ios

I'm using Wikitude and PhoneGap for my augmented reality mobile app project in xcode5. I don't what mistake I had done during installation. I have already read all the documentation related to this setup.
http://www.wikitude.com/external/doc/documentation/3.0/phonegap/setupguidephonegapios.html
Besides that, I have already downloaded Wikitude Phonegap plugin sample from Github but I still don't have any idea to integrate the samples into my project.
https://github.com/Wikitude/wikitude-phonegap-samples
I have already inserted this code into config.xml.
<feature name="WikitudePlugin">
<param name="ios-package" value="WTWikitudePlugin"/>
</feature>
But I am not understanding this part.
JAVASCRIPT INTERFACE
It is straightforward to use the Wikitude Plugin within your PhoneGap application.
We wrapped all cordova.exec calls into a separate JavaScript wrapper which handles location updates and some more functionality behind the scenes.
You will mainly work with the WikitudePlugin where all you have to do is to call Wikitude.isDeviceReady(successCallback, errorCallback) and in your successCallback, you can call WikitudePlugin.loadARchitectWorld(successCallback, errorCallback, "path/to/your/world").
What are the other kinds of files I need to add for running Wikitude sdk in my mobile app project?
Why does it happen?

you are referencing an outdated documentation from Wikitude. Have a look at the current documentation which describes the setup process using PhoneGap 3.0 + Plugman.
After you have done this, all you need to do is to add your 'Architect World' which is the 'assets' folder in the sample application. You can structure this folder as you want but it has to include a html file which is the starting point for the Architect World.
To interact with the Wikitude SDK, there is the WikitudePlugin.js file, which wraps all the calls from JS to the native ObjC application. Have a look at the sample application how to use the WikitudePlugin.js, but in general you need to check if the device is able to run an Architect World (WikitudePlugin.isDeviceSupported) and after this, use the success callback to load the Architect World with WikitudePlugin.loadARchitectWorld.

Related

How to obfuscate Objective C code of Cordova hybrid app?

I have an Ionic v1 / Cordova mobile app and I need to obfuscate all sources. For obfuscation of Javascript I have used https://github.com/javascript-obfuscator/javascript-obfuscator and for Java for Android I have used https://github.com/greybax/cordova-plugin-proguard. As I couldn't find any cordova plugin for obfuscation of Objective C and I decided to use https://github.com/preemptive/PPiOS-Rename.
However, after obfuscation with PPiOS-Rename, there seems to be a problem with obfuscation of cordova plugins and I'm unable to run the app correctly. If I remove the plugins from obfuscation process the app would work but I need to make obfuscated also the code of plugins.
Does anybody have experience with obfuscating the Objective C code of Cordova app please?
Thanks!
The problem that you have is that Cordova relies on a bridge between your app code written in Javascript and the underlying native code in order to function.
By obfuscating all of the Objective C code, the Javascript layer is unaware of this, and can no longer find the native class names it is looking for.
For example, let's suppose you have included cordova-plugin-device in your app.
Its <feature> definition for iOS maps the Device feature name to the CDVDevice class.
Let's suppose your Cordova app calls the plugin method device.getInfo().
This in turn invokes a call to cordova.exec() which calls the Device feature with the getDeviceInfo action.
Under the hood, Cordova looks up Device to find the native class name it's mapped to (CDVDevice) and then on the iOS platform it attempts to call the getDeviceInfo() member function on this class.
However, by running the PPiOS-Rename tool, you have obfuscated both the class name (CDVDevice) and the function name (getDeviceInfo()) so Cordova cannot find the class or function to invoke, so will throw an error.
In this case you'd need to exclude the CDVDevice using the filter option provided by PPiOS-Rename, for example:
ppios-rename --analyze -F 'CDVDevice' /path/to/program.app/program
If you wish to proceed with obfuscating the Objective C layer of your Cordova app, you will have to add exclusions for all of the class and function names which Cordova calls explicitly from the Javascript layer.
This includes any Cordova plugin interface classes in your project, and possibly classes belonging to the Cordova framework itself (as cordova-plugin-proguard does for ProGuard on Android.

How to write custom / own plugin for ionic framework

Im trying to write own plugin to call native iOS functions. Can any one guide me in writing own plugin & consume it to my ionic application.
Thanks in advance
It can be done using Cordova's Plugin Development Guide.
from docs it says,
Plugins comprise a single JavaScript interface along with
corresponding native code libraries for each supported platform. In
essence this hides the various native code implementations behind a
common JavaScript interface.
you can check these articles for kick-start.
Plugin Development Guide
How to write Cordova Plugins
Tutorial

IOS Phonegap 3.X: Lock page orientation during runtime

I am developing a webapp using phonegap + sencha touch, and I want to lock orientation on certain pages during runtime. I found this phonegap plugin , but it's not working for phonegap 3.X.
I also found something about a js function which named 'shouldRotateToOrientation', is it provided by phonegap? And it seems just works in multi-page(html files) app, my sencha touch app only have one html file.
So, how can I do that? Any help from you will be greatly appreciated.
i know this is not really a valid "answer" but SO doesn't let me comment with <50 rep. anyway, i noticed it's not that difficult to set up an old plugin to be used with cordova 3+. adhere to the folder structure (which you can see in existing cordova plugins like "device"), create a plugin.xml and install the plugin with plugman. read the documentation about plugin development and you should be good.
you will especially have to replace the function header in the ios files. replace
-(void)setAllowed:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
with
- (void)setAllowed:(CDVInvokedUrlCommand*)command
This is a phonegap plugin for android/ios.
https://github.com/yoik/cordova-yoik-screenorientation

Using Protocol buffers in PhoneGap - iOS

I have used the c++ google protobuf classes in iOS using the native app approach, i.e. using Xcode, objective c, cocoa etc.
Now, I want to migrate to hybrid apps and I have explored the options on web, and according to my requirements i'm down to PhoneGap and Titanium. That will require me to use JavaScirpt, HTML5 (JavaScript only in Titanium as per my understanding) jQuery etc.
My question is, HOW am i supposed to access the my c++ protobuf classes from javascript. (i have no expertise in JavaScript).
I am also open to opinions on which hybrid-app framework to use.
Lords of web-dev....guide me.
With PhoneGap, if there is a phone feature that the PhoneGap APIs do not currently expose, or if you have some specialised native algorithm / function that you wish to access, then you need to write a plugin.
PhoneGap plugins provide a standardised mechanism for packing native code and accessing its functionality via JavaScript. See the PhoneGap Plugin Development Guide.
Personally I think PhoneGap is the best hybrid framework, it had been around for a while, is well documented, and has a healthy community.
This is an old question, but you can always use the 100% JavaScript implementation of ProtoBuf in your JavaScript code. It works well, and you can even precompile the .proto file if you want.
In Cordova it would be better to create a plug-in, but if you don't have time or skill to do that, the linked code works well.

Phonegap + JQM - Phonegap.js?

I am just getting into building a basic app using JQM and Phonegap.
I am using the Phonegap Cloud Builder and so far everything is OK!
But now I want to try and use some of the phones features e.g. the camera. I have read about people doing this successfully using JQM, but the hurdle I am stumbling on involves 'phonegap.js'
As I understand, this file is created typically when a new project is created (using Eclipse of XCode etc). My 'app' is being created by hand (hence using the Cloud Builder) and therefore I have no access to phonegap.js.
All the documentation I find is old and says the files are in the zip download, but they are not. I also figured that the Cloud Builder creates this file, but no idea where it places it in relation to the index page for me to reference it.
So, how can I get hold of the phonegap.js library to use the phones camera, when I am not using an IDE (this is likely to change if there is no way to get the file without one)
Download PhoneGap here: http://phonegap.com/download/, depending on platform you are developing follow appropriate tutorial included in documentation. Ether way you will be having www folder inside your project with phonegap.js file in it. Copy your jQm web application to www and append phonegap.js file in of your index.html. Now you will be able to compile native application that can access phone resources.

Resources