mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(device-feedback): add feedback interface
feat(device-feedback): add feedback interface
This commit is contained in:
commit
1cf3d7da82
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user