mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-02 00:07:23 +08:00
feat(device-feedback): add DeviceFeedback plugin (#696)
This commit is contained in:
@@ -32,6 +32,7 @@ import { DatePicker } from './plugins/datepicker';
|
|||||||
import { DBMeter } from './plugins/dbmeter';
|
import { DBMeter } from './plugins/dbmeter';
|
||||||
import { Deeplinks } from './plugins/deeplinks';
|
import { Deeplinks } from './plugins/deeplinks';
|
||||||
import { Device } from './plugins/device';
|
import { Device } from './plugins/device';
|
||||||
|
import { DeviceFeedback } from './plugins/device-feedback';
|
||||||
import { DeviceAccounts } from './plugins/deviceaccounts';
|
import { DeviceAccounts } from './plugins/deviceaccounts';
|
||||||
import { DeviceMotion } from './plugins/devicemotion';
|
import { DeviceMotion } from './plugins/devicemotion';
|
||||||
import { DeviceOrientation } from './plugins/deviceorientation';
|
import { DeviceOrientation } from './plugins/deviceorientation';
|
||||||
@@ -139,6 +140,7 @@ export * from './plugins/datepicker';
|
|||||||
export * from './plugins/dbmeter';
|
export * from './plugins/dbmeter';
|
||||||
export * from './plugins/deeplinks';
|
export * from './plugins/deeplinks';
|
||||||
export * from './plugins/device';
|
export * from './plugins/device';
|
||||||
|
export * from './plugins/device-feedback';
|
||||||
export * from './plugins/deviceaccounts';
|
export * from './plugins/deviceaccounts';
|
||||||
export * from './plugins/devicemotion';
|
export * from './plugins/devicemotion';
|
||||||
export * from './plugins/deviceorientation';
|
export * from './plugins/deviceorientation';
|
||||||
@@ -248,6 +250,7 @@ window['IonicNative'] = {
|
|||||||
DBMeter,
|
DBMeter,
|
||||||
Deeplinks,
|
Deeplinks,
|
||||||
Device,
|
Device,
|
||||||
|
DeviceFeedback,
|
||||||
DeviceAccounts,
|
DeviceAccounts,
|
||||||
DeviceMotion,
|
DeviceMotion,
|
||||||
DeviceOrientation,
|
DeviceOrientation,
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import {Plugin, Cordova} from './plugin';
|
||||||
|
/**
|
||||||
|
* @name DeviceFeedback
|
||||||
|
* @description
|
||||||
|
*
|
||||||
|
* Plugin that lets you provide haptic or acoustic feedback on Android devices.
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```
|
||||||
|
* import { DeviceFeedback } from 'ionic-native';
|
||||||
|
*
|
||||||
|
* DeviceFeedback.acoustic();
|
||||||
|
*
|
||||||
|
* DeviceFeedback.haptic(0);
|
||||||
|
*
|
||||||
|
* DeviceFeedback.isFeedbackEnabled()
|
||||||
|
* .then((feedback) => {
|
||||||
|
* console.log(feedback);
|
||||||
|
* // {
|
||||||
|
* // acoustic: true,
|
||||||
|
* // haptic: true
|
||||||
|
* // }
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
plugin: 'cordova-plugin-velda-devicefeedback',
|
||||||
|
pluginRef: 'plugins.deviceFeedback',
|
||||||
|
repo: 'https://github.com/VVelda/device-feedback',
|
||||||
|
platforms: ['Android']
|
||||||
|
})
|
||||||
|
export class DeviceFeedback {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide sound feedback to user, nevertheless respect user's settings and current active device profile as native feedback do.
|
||||||
|
*/
|
||||||
|
@Cordova({ sync: true })
|
||||||
|
static 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.
|
||||||
|
*/
|
||||||
|
@Cordova({ sync: true })
|
||||||
|
static haptic(type: number): void { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if haptic and acoustic feedback is enabled by user settings.
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
static isFeedbackEnabled(): Promise<{ haptic: boolean; acoustic: boolean; }> { return; }
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user