Code: Select all
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {100, 300, 300, 300};
v.vibrate(pattern, -1);
NotificationCompat.Builder builder = new
NotificationCompat.Builder(this,"CHANNEL_ID");
Intent resultIntent = new Intent(this, ManageSalesMainActivity.class);
resultIntent.putExtra("order_status",message_status);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 1,
resultIntent, PendingIntent.FLAG_IMMUTABLE);
builder.setContentTitle(Objects.requireNonNull(remoteMessage.getNotification())
.getTitle());
builder.setContentText(remoteMessage.getNotification().getBody());
builder.setContentIntent(pendingIntent);
builder.setStyle(new
NotificationCompat.BigTextStyle().bigText(remoteMessage.getNotification()
.getBody()));
builder.setAutoCancel(true);
builder.setSmallIcon(R.drawable.go_local_logo_without_bg);
builder.setVibrate(pattern);
builder.setPriority(Notification.PRIORITY_MAX);
mNotificationManager=NotificationManager)getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String ChannelId = "Channel_id";
Code: Select all
NotificationChannel channel = new NotificationChannel(
channelId,
"Channel human readable title",
NotificationManager.IMPORTANCE_HIGH);
channel.enableLights(true);
channel.enableVibration(true);
channel.setVibrationPattern(pattern);
channel.canBypassDnd();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
channel.canBubble();
}
mNotificationManager.createNotificationChannel(channel);
builder.setChannelId(channelId);
}
mNotificationManager.notify(1000, builder.build());