简体   繁体   中英

Android background notifications vibration

I think like I searched whole internet at this point and time my question is: Is it even possible to make android phone vibrate on firebase notification? I tried everything but I was only able to make it vibrate in foreground.

class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
    val vibrator = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
    vibrator.vibrate(1000)
}

}

This is piece of code that I ended up with. Super simple but working

please confirm you have add vibrate permission on manifest file or not

<uses-permission android:name="android.permission.VIBRATE"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM