####A third-party Phonegap plugin for iOS and Android that implements the Moodstocks v4 SDK.
Developed by Thomas Forth at imactivate. Tested for Android with Phonegap v3.6, on Windows and Mac, in Eclipse. iOS compatibility tested with OS X Yosemite, and Phonegap 4.3.
Watch this video for Android installation.
Watch this video for iOS installation.
Then check for any additional steps that have been added since recording below.
Installation is via the Phonegap CLI as with the v3.7 plugin but requires slightly different steps later in the installation.
- The native-code portion of the Moodstocks v4.x.x SDK (Eclipse) needs downloading and adding to the project.
- The MainActivity.java class needs moving to the
your.package.name
package you chose when creating your project using the Phonegap CLI. - Replace the
_yourKey_
and_yourSecret_
placedholders in MainActivity.java with your Moodstocks key and secret. - All references to
com.imactivate.MS4TOM
need changing toyour.package.name
. This includes in theAndroidManifest.xml
and in each Java file includingimport com.imactivate.MS4TOM.R
. - In
AndroidManifest.xml
theandroid:name="<name>"
property of the main activity toandroid:name="MainActivity"
. - (Depending on the phonegap version you use some or all of these changes to
AndroidManifest.xml
may not be required). Theandroid:debuggable="true"
property needs removing. Theandroid:minSdkVersion="10"
property needs changing toandroid:minSdkVersion="11"
. Optionally, replaceandroid:theme="@android:style/Theme.Black.NoTitleBar"
withandroid:theme="@android:style/Theme.Holo.NoActionBar"
. - The camera plugin now requires an SDK with API>18. If you are using an older SDK version right-click on the project title in Eclipse and select Properties -> Android. Then change the Project Build Target to a Platform version of at least 4.4.2 (API Level 19). You can safely delete the
import org.apache.cordova.file.FileUtils
line inCameraLauncher.java
if you still have issues.
Your project should now compile and install. Additionally you may want to install the Phonegap v4 Demo App.
In assets/www/
replace index.html
with the index.html
in the Moodstocks v4 Phonegap Demo and add the content of the Demo's img
folder to assets/www/img
.
Installation on iOS is easy. See the video.
- Create a new phonegap iOS project.
- Add the Moodstocks SDK Framework.
- In
MainViewController.m
, find thewebViewDidfinishLoad
method and addself.webView.backgroundColor = [UIColor clearColor];
andself.webView.opaque = NO;
to the method body. This makes the MainViewController transparent so they ScannerViewController is visible through it. - In
MS4Plugin.m
change the values ofMS_API_KEY
andMS_API_SECRET
. - (optional) In
Staging/config.xml
change theDisallowOverscroll
property totrue
.
Your project should now compile and install. Additionally you may want to install the Phonegap v4 Demo App.
In Staging/www/
delete index.html
and replace it with the index.html
from the Moodstocks v4 Phonegap Demo. Add the content of the Demo's img
folder to Staging/www/img
.
Offline bundles are supported on both iOS and Android. A *.bundle file should be requested directly from Moodstocks. Place it in the Resources folder for iOS projects and in the Assets folder for Android projects. Bundles must match the API key in MS4Plugin.m for iOS projects and in MainActivity.java for Android projects.
As of 2015-10-06 the plugin works in portrait and landscape mode on both iOS and Android. Make sure that useDeviceOrientation
is set true. On iOS you will need to enable Landscape views (Landscape Left and/or Landscape Right) in the the project properties. You’ll find this is in the General>Deployment Info>Device Orientation section.
As of v4.1.7 The Moodstocks SDK does not include bitcode support. The workaround is simple. http://stackoverflow.com/questions/30848208/new-warnings-in-ios9
We know of people successfully using our plugin with every 3.x and 4.x version of Cordova. Cordova 5.x introduces a large number of small bugs. We have fixed most of them, with a few left to squash. Unfortunately these fixes break compatibility with previous version of Cordova and we expect many of them to fixed within Cordova itself in future 5.x versions. For now, we recommend avoiding Cordova 5.x, and we cannot provide support for it.
On 2015/04/15 the package id of the default cordova camera plugin changed from org.apache.cordova.camera to cordova-plugin-camera. We have updated our plugin and this should cause no problem.
*At the Phonegap level the API is largely unchanged from the Moodstocks v3.7 phonegap plugin and porting should be straightforward.
- The
scanSuccess
function now returns a JSON object with three properties,format
,value
, andrecognisedFrame
. CurrentlyrecognisedFrame
is unimplemented. - The
scanOptions
object now requires ascanType
to be defined. This can be eitherauto
ormanual
. Both use cases are included in the demo app. - Bundle loading is supported on Android, and soon on iOS. A partial implementation is included in the demo app but not activated.
- Camera roll recognition is supported by a completely new function and demonstrated in the demo app.
This release drops support for Android 2.x. Users who require this should use the Moodstocks v3.7 phonegap plugin. Android Studio is not supported; Phonegap is the barrier to this.
Separate tasks for scanning and the main UI have been replaced with a single task containing multiple fragments -- one for Manual Scanning, one for Automatic Scanning, and one for the phonegap webview. The main task contains the Moodstocks Scanner object and handles synchronisation. The phonegap webview is loaded on application launch and scanner fragments are loaded when required and destroyed when closed.
A new callback system has been implemented which does not rely on the startActivityForResult
method typical in Phonegap plugins. This is necessary because of the move from Tasks to Fragments.
The old pattern of attaching and detaching the cordovaWebview to the scanningView has been replaced with a much more efficient and reliable pattern. Now, the MainViewController contains the cordovaWebivew and is transparent. It runs on top of a separate ScannerViewController that handles scanning which is loaded and unloaded behind it when needed.
A new callback system has been implemented which uses NSNotificationCenter to communicate between the ScannerViewController and the cordovaWebview within the MainViewController.
We do not return the frames that were recognised. We have this feature running on both iOS and Android for both Manual and Auto scanner sessions but difficulties implementing the feature on iOS mean we are not making this publicly available. Specifically, returning query frames in iOS from the native code to the CordovaWebView resulted in unacceptable performance. Significant architecture changes will be required to allow the user to specify whether they want queryFrames returned or not so this slowdown could not be avoided in the majority of cases where the user does not want the queryFrame returned. If you need this feature, please get in touch and I will be happy to work with you to make it happen.
Copyright (c) 2015 Moodstocks SAS and imactivate. License is MIT and included.