This is the plugin I'm trying to use: https://github.com/blinkmobile/cordova-plugin-sketch
Q) I'm trying to get the cordova sketch plugin working so I can annotate an image, but can't get this to initialise properly. What am I doing wrong?
The page loads fine and I don't get any error alert, which is the second callback function you can see.
Yes, I'm running on the device. I know cordova plugins don't work in the browser.
Page:
<ion-navbar *navbar header-colour>
<button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Sketch</ion-title>
</ion-navbar>
<ion-content padding>
<img #sketchElement src="img/sketchpad.jpg" height="400" width="600"/>
</ion-content>
Class:
import {NavController, NavParams} from 'ionic-framework/ionic';
import {Page, ViewController, Platform, Alert, Modal, Events} from 'ionic-framework/ionic';
import {forwardRef} from 'angular2/core';
import {OnInit, OnDestroy} from 'angular2/core';
import {ViewChild, ElementRef} from 'angular2/core';
@Page({
templateUrl: 'build/pages/sketch/sketch.html'
})
export class SketchPage {
@ViewChild('sketchElement') sketchElement:ElementRef;
constructor(
private _platform: Platform,
private _nav: NavController,
private _viewController: ViewController,
private _events: Events) {
}
ngOnInit() {
this._platform.ready().then(() => {
if(navigator && navigator.sketch) {
navigator.sketch.getSketch(
function() {
},
function(message) {
alert(message);
},
{
destinationType: navigator.sketch.DestinationType.DATA_URL,
encodingType: navigator.sketch.EncodingType.JPEG,
inputType : navigator.sketch.InputType.FILE_URI,
inputData : this.sketchElement.nativeElement.src
});
alert('done')
}
});
}
}
Thanks!