This repository was archived by the owner on Apr 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Capacitor } from "@capacitor/core" ;
21import { Haptics } from "@capacitor/haptics" ;
32import { NotificationType } from "@capacitor/haptics/dist/esm/definitions" ;
43
54export const vibrate = async ( millis = 250 ) => {
6- if ( Capacitor . isNativePlatform ( ) ) {
5+ try {
76 await Haptics . vibrate ( { duration : millis } ) ;
8- } else {
9- window . navigator . vibrate ( millis ) ;
7+ } catch ( error ) {
8+ console . warn ( error ) ;
109 }
1110} ;
1211
1312export const vibrateSuccess = async ( ) => {
14- if ( Capacitor . isNativePlatform ( ) ) {
13+ try {
1514 await Haptics . notification ( { type : NotificationType . Success } ) ;
16- } else {
17- window . navigator . vibrate ( [ 35 , 65 , 21 ] ) ;
15+ } catch ( error ) {
16+ console . warn ( error ) ;
1817 }
1918} ;
You can’t perform that action at this time.
0 commit comments