The push-notifications to the app are always sent, that's not the problem. The problem is that the phone vibrates if it receives a new notifications from the app only if the app is open and the phone is not locked. If either the app is not open or the phone is locked, the phone will not vibrate on received notifications. Would there be a way to make the phone vibrate on received notifications even if it is locked or the app is not open? What could be the problem? From what I found, the notifications are created with the help of the following code:
public class NotifyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(
remoteMessage.getMessageId(),
1,
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_paperplane)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setVibrate(new long[] { 150, 300, 150, 600})
.setAutoCancel(true)
.build());
super.onMessageReceived(remoteMessage);
}
}
The manifest has the vibrate and wake_lock permissions:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" /
in the notification payload add this :
This will run sound if it's not silence mode and vibrate when it's vibration mode
There's a big difference between firebase data messages and firebase notification messages.
From the docs:
And for data messages
Means you can't handle notification messages that are received in background. I would send a data message that just contains title and message and parse it manualy in your app. This allows you to enable vibrations.
Alternatively, if using the firebase console, you can enable "sound" in the expanded options when sending a message.