CanvasCamera for iOS PhoneGap / Cordova - ios

First of all, I'm really new to Cordova and Xcode and I'm trying to create an inline QR Code scanner from and HTML 5 app (or at least see if it's possible with this plugin).
I'm trying to follow the instructions from https://github.com/daraosn/Cordova-CanvasCamera and I am unsure what format or how to edit the config.xml in my project.
The instructions say:
"Edit your config.xml and add CanvasCamera into your Plugins list." but i dont know what this means or what format it should follow.
Also, when I add the plugins to the Plugin folder in the project, Xcode throws an error saying:
"'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode".
I know that getUserMedia isnt support in Safari/iOS so it's pushing the boundaries a bit. If all else fails, i'll just use the input type=file and access the camera that way.

That plugin you reference looks severely dated. My best guess is, for your config.xml, add:
<plugin name="CanvasCamera" />
once you copied the files into your directory per those instructions.
Also, you could check out https://github.com/donaldp24/CanvasCameraPlugin. You can install it by running "cordova plugin add https://github.com/donaldp24/CanvasCameraPlugin.git && cordova prepare".
Hope this helps.

I found a plugin (http://scandit.com) which is much better than what i was originally trying to achieve.
The only downside is that it's a premium service ($200/month), however the upsides are: super easy to install, is really really fast at decoding (doesn't need to focus, shade doesn't matter), available on plenty for platforms, good documentation.
Another point was that it is a fullscreen camera plugin, which actually works better than inline, what we initially wanted.
Hope it helps anyone else.

Related

How can you permanently change iOS app configuration in Meteor Cordova?

Every time I meteor build, I have to open XCode and do the following:
remove and add an item from "Link Binary With Libraries" (Facebook SDK)
add a URL Type (custom URL scheme for my app)
add a "Required device capabilities" to "Custom iOS Target Properties"
How can I edit my Meteor project to have these steps done automatically, and to auto add things to AndroidManifest.xml?
In some way use mobile-config.js or cordova-build-override?
I'm happy to see another guy who is trying to build a hybrid application using Meteor / extending a Meteor Cordova iOS app, since I'm facing the very same issues. So I'm very happy to share my experiences and approaches with you. :-)
So far, I ended up with the following approach:
I created a base template for my iOS app using meteor build (not meteor run ios-device, since I did not know if Meteor does some optimizations for production code).
Then, I copied the whole Xcode project under /platforms/ios to another loaction and used this new project as my "master" project from then on. This project is being enriched with native code, e.g. it also includes the Cocoa Pods I'm needing.
Of course, I also did not want to copy files each and every time I trigger a new Meteor build. At least, I would like to have the Staging/www folder updated, as this is happening quite frequently.
So my first (rather naive) approach was
delete the Staging/www folder in the master project
replace it with a relative link (using Xcode's linking functionality) to the Staging/www folder inside the .meteor/local/.../ios/ project
This approach did not work, since the shell script used in the Meteor Xcode project can't handle these links.
My second approach is to create a symlink on the filesystem level instead. This works as it should, and I'm able to build the project in Xcode as it should.
I could have followed the same approach for the Cordova plugins folder, but I've decided to replace the plugins manually in order to get a better control over them, even it means a bit more effort then.
Having the symlink in place also means that Xcode's version management (and also SVN which I am using for everything) will ignore everything below Staging/www, which is good in my opinion, because I'm already versioning the webapp code in the Meteor project itself.
BTW: I've started a discussion thread on hybrid mobile app on the Meteor forums as well, but so far it did not get too much attraction:
https://forums.meteor.com/t/building-a-hybrid-meteor-cordova-app-share-experiences/8212
Maybe we could follow up on Meteor-specific things there, to have the Meteor community participate in the discussion?
EDIT: I would also like to share an approach that failed completely, at least for me, maybe I was too dumb... Before I used Meteor's Xcode template as the starting point, I also tried it "the other way round", i.e. I started with my already existing Xcode app project and tried to include Meteor's / Cordova's part by hand. Using this approach, I never managed to set everything up correctly. I had lots of troubles and also had to tweak a lot of the compiler / linker flags to even get the code compiling. This grew me a lot of gray hairs. But even after I managed to get everything to compile, Meteor hang during startup - and I never figured out why.
One remaining problem I'm still facing is that Meteor's hot code push functionality seems to have some severe issues on iOS, that are also documented as GitHub issues. It can happen that the iOS app gets completely broken and needs to be reinstalled. I tried the mdg:reload-on-resume package, but this did not work as it should and made things even worse. As far as I can tell from the GitHub discussions, one should better disable hot code push until the Meteor team has addressed these issues. Breaking the app completely due to code pushes is not what my users would expect.
Unfortunately plist values (and assumably AndroidManifest.xml as well) can only be changed by a plugin:
Add entry to iOS .plist file via Cordova config.xml

Can't access camera PhoneGap 3.3

The Problem
I'm attempting to build my first PhoneGap app for iOS. I am using version 3.3.x.
For whatever reason, I can't seem to get the Camera feature to work on my iPhone 5S (haven't tested any other devices).
What I've tried
I've installed the Camera Plugin
I've added the feature to the config.xml file on the platform/ios/www level.
I've tried using PhoneGap docs examples.
I've tried using other online examples.
I've tried buying the PhoneGap 3 book and going step-by-step through their method.
None of that seems to matter
What works
I've used a <input type="file" accept="image/*;capture=camera">, this works, but it's not really what I'm looking for. I'm trying to actually access the Camera API.
Geolocation plugin I've tried and it works fine.
Accessing external API's I have gotten to work.
What also doesn't work
Contacts Plugin also doesn't seem to be working with the examples on the PhoneGap Docs.
Possible Clues
I am running / building the app from within Xcode. I've also tried building using the Command-Line Tool but I'm not sure how to run it on my iPhone once it's been built through CLT. I don't know if this matters or not.
There seems to be a "lag" in launch time when I include any scripts associated with the Camera API.
Since I've used so many different code snippets from verified sources, I doubt it has to do with the js, html or css that I'm writing. I believe this to be a dependency issue, but I have no idea what it could be, and there's not much help out there for PhoneGap yet.
Any advice or suggestions would be greatly appreciated!

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.

Integrating phoneGap with native iOS app

i'm trying to create an app which uses the combination of native functionality and the phoneGap framework. The native app has a button, upon the click of which the phoneGap ui has to be added to the view. Is there any way to achieve this? Are there any tutorials for the same?
Yes, this is possible. Although you might be getting yourself into some headaches. My app kind of goes the other way around, it's mostly phonegap, but occasionally i'll pop open a view that is native. Here is the link to code that shows an excellent example of how to switch between the iOS and phonegap worlds.
new updated recommended article (see update below)
These files represent a standard plugin used in phonegap. In this particular plugin, a native view is opened on top of a phonegap view. Notice you have a custom xib and everything. This plugin can be modified to display any xib with any functionality you could think of.
If you implement this plugin you will easily see how to jump back and forth. I've successfully heavily modified these classes to add LOTS of native capabilities to my phonegap project. Also you should probably check out the official phonegap guide to phonegap plugins. Here
Important Edit
Was informed original linkwas broken (not terribly surprised as this answer is very old and i've long since moved away from Phonegap) so I replaced the original link with an article that shows how to do these plugins well. In the article it explains the link is broken and gives several links where these older files are maintained, but in fact those are broken as well. Here is a branch of one of them I found that still hosts the original files on an "archive" branch. But I haven't investigated whether these files are wildly different from my original work. Good luck!
That's not how Phonegap is meant to be used.
To achieve what you are asking for you just need to create a Phonegap app and add the extra native functionality by writing a Phonegap plugin in Objective-C. You may add as much native code as you want.
I'm actually wanting to do the same thing as the original poster. Theoretically it would be comparatively easy, but non-trival to do. I'd love it if there was a PhoneGapView that one could integrate into an existing project. Bonus points if said PhoneGapView could be integrated in Interface Builder as a re-sizeable and re-positional object, basically think of it as an Object that extends UIWebView.
This is wishful thinking on my part seeing as this is how the higher-ups want my project.

finding unsupported apis with os version

I've developed and application for iPhone. It works fine on os4 but it does not work on os3.1. In fact works but there are some problems; after splash screen a what screen appears. while I leaving the application I can see the application is opened successfully but just see while exiting.
So I wonder if there is a tool which says which apis have problems with os3.1? So I have a chance to replace them.
If you want to check a specific API, just run this in your code somewhere with an appropriate response. For example, to see if print is supported, run this...
if (NSClassFromString(#"UIPrintInfo")) {
}
Set your project's Base SDK to iphone-os-3-1, then build. All the error messages about classes, methods, and functions that don't exist must designate things added since iphone-os-3-1, since your project built and linked fine against the iphone-os-4-0 SDK.
If you don't have the iphone-os-3-1 SDK, try this instead:
Open your project's Build Settings.
Find the "Preprocessor Macros" setting.
Edit it and add __IPHONE_OS_VERSION_MAX_ALLOWED=30100
Now, try building. This should cause everything introduced after iOS 3.1 to be labeled unavailable, producing the same errors as if you had switched to the iphone-os-3-1 SDK.
It's a good idea to get a second installation of Xcode for this situation, in this case you need 3.2.1 with SDK 3.1.3 - I wish I could help you with a download link since it is no longer shown on Apple's page, but I have googled in the past and found direct, official download links which will work as long as you are signed in with your developer account, so good luck.
The annoying bit is that you need to go through your project files and set "Base SDK" to 3.1.3 and then back once you have completed the exercise. But it is the easiest way to flag what you can't do in 3.1.3. "sudo rm -rf" (I feel nervous even typing that) has an excellent method there but you need to have an inkling of what might be safe and what might not before you implement it or else you end up with code 10x the size it needs to be.
Apple really needs to sort out this issue - hopefully by flagging methods that are prior to your specified "Deployment Target", in the same way that deprecated methods are flagged.

Resources