I have an ionic(v1) app in which push notifications are sent through node-gcm and received by ngCordova push plugin. By default the phone vibrates when there is a push notification. It even vibrates when the app is open. How can I make the phone vibrate only when the app is running in background. The phone shouldn't vibrate when the user is using the app.
Asked
Active
Viewed 396 times
1 Answers
1
you can use cordova-plugin-vibration
installation :cordova plugin add cordova-plugin-vibration
you can cancel vibration like this navigator.vibrate(0)
more https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-vibration/

Edison Augusthy
- 1,535
- 17
- 32
-
This has to work in correlation with push plugin. When the app is opened it shouldn't vibrate. When the app is closed it should vibrate. – Puneet Apr 18 '17 at 07:53
-
http://stackoverflow.com/questions/29606012/how-to-check-app-running-in-foreground-or-background-in-ionic-cordova-phonegap this help you to find current state of the app.after cheking this u can use vibration -plugin according to the state ryt..? – Edison Augusthy Apr 18 '17 at 08:12