Hi all,
I want to implement 3D touch on my application, however when going to the native docs for it https://ionicframework.com/docs/v2/native/3d-touch/ and copy the code into my project I can many errors. I have install the plugin successfully as well.
The code is
import { ThreeDeeTouch, ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch } from '@ionic-native/three-dee-touch';
constructor(private threeDeeTouch: ThreeDeeTouch) { }
this.threeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable));
this.threeDeeTouch.watchForceTouches()
.subscribe(
(data: ThreeDeeTouchForceTouch) => {
console.log("Force touch %" + data.force);
console.log("Force touch timestamp: " + data.timestamp);
console.log("Force touch x: " + data.x);
console.log("Force touch y: " + data.y);
}
);
let actions: Array<ThreeDeeTouchQuickAction> = [
{
type: 'checkin',
title: 'Check in',
subtitle: 'Quickly check in',
iconType: 'Compose'
},
{
type: 'share',
title: 'Share',
subtitle: 'Share like you care',
iconType: 'Share'
},
{
type: 'search',
title: 'Search',
iconType: 'Search'
},
{
title: 'Show favorites',
iconTemplate: 'HeartTemplate'
}
];
this.threeDeeTouch.configureQuickActions(actions);
this.threeDeeTouch.onHomeIconPressed().subscribe(
(payload) => {
// returns an object that is the button you presed
console.log('Pressed the ${payload.title} button')
console.log(payload.type)
}
)
The issue that i get is Unexpected token. A constructor, method, accessor, or property was expected.
Also is there a specific place this code should go since its accessible from the devices home screen? If anyone has used it before it would be great help.