Example of using Cordova Camera in a ionic2 application
Only tested in Android
If you don't have it already, first install the latest ionic2 and cordova, i noticed that it was a good idea to uninstall my really old cli:s first
install
$ npm uninstall -g ionic
$ npm install -g ionic
$ npm uninstall -g cordova
$ npm install -g cordova
$ git clone https://github.com/marcusasplund/ionic2-camera-demo.git
$ cd ionic2-camera-demo
$ npm install
$ npm run build
$ ionic cordova build android
install .apk and test
(heads up: this project is written in typescript, if you want plain js, skip the flag --ts)
$ ionic start ionic2-camera-demo --v2 --ts
$ cd ionic2-camera-demo
$ ionic cordova plugin add cordova-plugin-camera --save
$ npm install --save @ionic-native/camera
Checkout the latest api:
https://ionicframework.com/docs/native/camera/
Heads up, in the file app.module.ts you need to add:
import { Camera } from '@ionic-native/camera';
And add Camera in the providers array, like so:
providers: [
StatusBar,
SplashScreen,
Camera,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
$ (sudo) typings install dt~cordova --global
$ (sudo) typings install dt~cordova-plugin-camera --global
download folder "app" from this project and replace folder "app" with this
$ npm run build
$ ionic cordova build android
install .apk and test