feat(device-feedback): add feedback interface

This commit is contained in:
Daniel Sogl 2018-03-16 15:17:29 +01:00 committed by GitHub
parent f11be24f74
commit 7cafebd0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,14 @@
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
export interface DeviceFeedbackEnabled {
/** Haptic Feedback */
haptic: boolean;
/** Acoustic Feedback */
acoustic: boolean;
}
/**
* @name Device Feedback
* @description
@ -19,8 +28,7 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
*
* this.deviceFeedback.haptic(0);
*
* this.deviceFeedback.isFeedbackEnabled()
* .then((feedback) => {
* this.deviceFeedback.isFeedbackEnabled().then(feedback => {
* console.log(feedback);
* // {
* // acoustic: true,
@ -29,6 +37,8 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
* });
*
* ```
* @innterfaces
* DeviceFeedbackEnabled
*/
@Plugin({
pluginName: 'DeviceFeedback',
@ -39,25 +49,25 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
})
@Injectable()
export class DeviceFeedback extends IonicNativePlugin {
/**
* Provide sound feedback to user, nevertheless respect user's settings and current active device profile as native feedback do.
*/
@Cordova({ sync: true })
acoustic(): void { }
acoustic(): void {}
/**
* Provide vibrate feedback to user, nevertheless respect user's tactile feedback setting as native feedback do.
* @param type {Number} Specify type of vibration feedback. 0 for long press, 1 for virtual key, or 3 for keyboard tap.
* @param type {number} Specify type of vibration feedback. 0 for long press, 1 for virtual key, or 3 for keyboard tap.
*/
@Cordova({ sync: true })
haptic(type: number): void { }
haptic(type: number): void {}
/**
* Check if haptic and acoustic feedback is enabled by user settings.
* @returns {Promise<any>}
* @returns {Promise<DeviceFeedbackEnabled>}
*/
@Cordova()
isFeedbackEnabled(): Promise<{ haptic: boolean; acoustic: boolean; }> { return; }
isFeedbackEnabled(): Promise<DeviceFeedbackEnabled> {
return;
}
}