mani kandan
mani kandan

Reputation: 439

Vibration not working in background mode (Ionic/capacitor))

I am working on a project in which the client needs vibration in background-mode. The method

vibrator.vibrate()

is working when the screen is on and app is open. But when the screen is off or app is minimized (not killed), the vibration function not working. Anybody know the solution?

Upvotes: 0

Views: 1236

Answers (2)

mani kandan
mani kandan

Reputation: 439

Ok I got how to get the background mode vibration in ionic app. Its possible using capacitor haptics vibration and foreground service plugins.

import {Haptics} from "@capacitor/haptics";
import { ForegroundService } from '@ionic-native/foreground-service/ngx';
...
constructor(private fg_service:ForegroundService){}
...
this.fg_service.start('App name', 'Service name', 'drawable/fsicon');
Haptics.vibrate({duration:500});

Upvotes: 1

dom.macs
dom.macs

Reputation: 796

Ionic Native Plugin - Vibration doesn't have the vibrate in background mode functionality yet. Please refer to this link for the open issue in Github.

Upvotes: 0

Related Questions