Custom Capacitor plugin to access the device's magnetometer sensor data for building compass applications on iOS and Android.
npm install capacitor-magnetometerCustom Capacitor plugin to access the device's magnetometer sensor data for building compass applications on iOS and Android.
``bash`
npm install capacitor-magnetometer
npx cap sync
* echo(...)
* startMagnetometerUpdates(...)
* stopMagnetometerUpdates()
* addListener('magnetometerData', ...)
* Interfaces
`typescript`
echo(options: { value: string; }) => Promise<{ value: string; }>
| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
--------------------
`typescript`
startMagnetometerUpdates(options: { frequency: number; }) => Promise
| Param | Type |
| ------------- | ----------------------------------- |
| options | { frequency: number; } |
--------------------
`typescript`
stopMagnetometerUpdates() => Promise
--------------------
`typescript`
addListener(eventName: 'magnetometerData', listenerFunc: (data: MagnetometerData) => void) => Promise<{ remove: () => void; }>
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------- |
| eventName | 'magnetometerData' |
| listenerFunc | (data: MagnetometerData) => void |
Returns: Promise<{ remove: () => void; }>
--------------------
#### MagnetometerData
| Prop | Type |
| ------- | ------------------- |
| x | number |
| y | number |
| z` | number |