OnDeviceReady not firing in iOS after upgrade to Cordova - ios

Someone asked a similar question and there are no good answers. So I thought I would help out...
I struggled with it for over two weeks and there was no easy way to find this. Apparently,you have to use the right Cordova js version with the Cordova iOS installation. It is not documented or displayed anywhere...but if you go into your cordova setup (wherever they are located on your hard drive), you can see the Cordova js file. Typically in the users/shared/cordova/framework/cordova.framework/www folder. Then copy the js file into your project, change references and that should do it.

Related

How to add cordova plugin in IOS cordva application?

i have cordova application in IOS.I am using x code to modifying in application. actually i am new to mac and IOS i want to know how to add custom or third party cordova plugin in my IOS application.Any tutorial or guidance any one recommend?
You use cordova, to add plugins you use:
cordova plugin add *pluginname*
in the installation process it will be added to all platforms that the plugin supports. For further information about that you have to read the readme files of the plugin. They explain that for every part of their plugins better than we can here in our short texts.
If you have any further question, just ask :) Have a nice day.
You can use the command cordova plugin add PLUGIN_NAME
Please check the documentation from Cordova for other options to update, remove, build the plugin https://cordova.apache.org/docs/en/3.1.0/guide/cli/index.html

Nativescript with AppBuilder plugin update

I am developing an app using nativescript with AppBuilder and Visual Studio. I am using a plugin called nativescript-pdf-view (https://github.com/Merott/nativescript-pdf-view). Everything worked fine until Apple changed one of their methods in xCode 8. See http://fluentreports.com/blog/?p=401 for details.
I have submitted a question to the author of the plugin 5 days ago, but have not received an answer yet, so I decided to make the change in the plugin code myself. The change is very simple, but after the update when I load the app to my test device, I still get the same error.
My question is: How does AppBuilder build plugins? Is it enough to update source code of the plugin to update it? How can I force the AppBuilder to rebuild this plugin?
I have a feeling the the plugin is cached somewhere because I get the same error message and stack trace even though the source code is changed.
Any suggestions are greatly appreciated.
In order to use a custom plugin in your project you have to update the reference in your package.json. For example in your case, you can:
Get the source code of nativescript-pdf-view.
Fix the issue you've noticed.
Build a .tgz from your modified source code (npm pack command should help you to create a .tgz).
Include the .tgz in your project (for example at the root level, right next to package.json).
Reference the .tgz in your package.json, so instead of having "nativescript-pdf-view": "1.0.0", you should have "nativescript-pdf-view": "file:nativescrip-pdf-view.tgz".
Build your project.
This way the custom plugin will be used instead of the one from npm.
There's no caching of plugins in the cloud builds. The process uses your package.json to install required dependencies.

Changes disappearing when building Cordova app for ios

I'm an absolute beginner with Cordova and was following this tutorial when I started experiencing my problem.
The tutorial is more aimed at building the project for android but I applied the same steps to create an ios build on my mac.
danieloram CordovaProject $ cordova run ios
the default project builds and runs fine but whenever I edit either the index.html or cordova.js files in the ios directory of the platforms folder and run the above command (or cordova build ios), all my changes revert back to the default code.. This behaviour isn't mentioned anywhere that I can see in the linked tutorial.
Am I missing something really obvious?
I haven't been able to find anything online about any other users experiencing this issue.. so I'm inclined to think it is trivial.
Seems I found my answer, and a quick one at that.
The tutorial did not explicitly state which index.html file I was to edit so I naturally assumed it was the file nested inside the platforms/ios directory.
These file however should not be edited as they are overwritten using the outermost index.html file in the myapp/www/ folder.
This SO answer sums it up perfectly with more detail.

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

phonegap.js (cordova.js) functionality missing, or invalid

Ok, trying to build out my first phonegap based project and I am coming to a point where I need to start tieing into the device such as the camera. Which I can't do due to errors like:
Can't find variable: FileUploadOptions
Which I have found means that I have to have this js file called phonegap.js. Which from what I have learned generates at the time of building out your app. However. Sometime in the recent past support for phonegap.js has been removed, and cordova.js is now apparently the file that replaces it. Which this did generate. However the function above for example, fails because there is no reference to such a function/class anywhere in cordova.js yet the cordova docs/help point to phonegap docs.. which tell you to include this plugin (which I do) and tells me how to do things which I follow to a letter so I can first try to get it working. So, this continues to fail.
I go out and find a copy of a phonegap.js but its useless to me as its an older version concept. 1.9.0 (and who knows which platform it was generated for) Either way for giggles I try with that one I get a syntax error. Soooo..
Can someone for the sake of my sanity tell me, one, why is it so hard for the docs to describe these things. two.. If the file is supposed to generate, but doesn't yet its required, what does one do?
It's been a long time since you asked your question so I will answer for PhoneGap version 3.3.
You need to build your project for iOS with phonegap local build ios. Then the phonegap.js file will in $PROJECT_ROOT/platforms/ios/www directory.
Make sure you include phonegap.js in your index.html file, near the bottom so that it is after any dependencies.
<script type="text/javascript" src="phonegap.js"></script>
You may see warnings that cordova.js is not found, but this is ok as long as you have phonegap.js.
For reference, Apache Cordova is an open source project and PhoneGap offers some extra features on top of Cordova.

Resources