Issue
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?
Solution
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});
Answered By - mani kandan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.