Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notification Not getting Sound And Vibration

I've used FCM Notifications in My app , I'm Receiving Them and it's showing Title And message Perfectly

But,When i'm receiving the Notification Im not getting any sound or vibration or any Led light indication

My Notification Builder Code is

    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

    builder.setSmallIcon(R.drawable.applogo);
    builder.setContentTitle(Title);
    builder.setContentText(Message);
    builder.setAutoCancel(true);
    builder.setSound(Uri.parse("file:///android_asset/notification.mp3"));
    builder.setContentIntent(pendingIntent);
    builder.setDefaults(Notification.DEFAULT_VIBRATE);
    builder.setLights(Color.RED, 1000, 300);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, builder.build());

Thanks in Advance.

like image 893
GuruCharan Avatar asked Oct 05 '17 12:10

GuruCharan


People also ask

Why is my phone not making sound when I get a notification?

Try these steps: Go to Settings > Sound & Notification > App Notifications. Select the app, and make sure that Notifications are turned on and set to Normal. Make sure that Do Not Disturb is turned off.

Why is there no notification sound on my Android?

Check and Increase Notification Volume Level Even if your ringtone volume is high, it wouldn't matter if notification volume is low. So you must check the notification volume level separately. To do so, go to Settings > Sounds and vibration > Volume. Increase the slider next to Notifications by moving it to right.

How do I fix silent notifications on Android?

Open your phone's Settings app. Notifications. Under "Lock screen," tap Notifications on lock screen or On lock screen. Choose Show alerting and silent notifications.

Why is my Android phone not notifying me when I get a text?

Check Notification Settings of Messages App You can check notification settings from System Settings > Apps and Notifications > Apps > Messages. Then click on the Notifications option and make sure All Messages notifications is toggled on. Also, Android supports multiple channels for notifications.


1 Answers

1. When you send push notification from firebase make sure that sound option enabled

like this enter image description here

2. Also make sure that you have added permissions in android manifest for vibrate.

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

3. If you are sending from server than use payload

notification payload of the notification there is a sound key.

From the official documentation its use is:

Indicates a sound to play when the device receives a notification. Supports default or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/.

{
    "to" : ".......",

    "notification" : {
      "body" : "body",
      "title" : "title",
      "icon" : "myicon",
      "sound" : "default"
    }
  }
like image 86
AskNilesh Avatar answered Sep 27 '22 19:09

AskNilesh