mgks / Android-SmartWebView

A simple use webview integrated w/ native features to help create most advanced hybrid applications.
https://mgks.dev/smart-webview
MIT License
570 stars 278 forks source link

Android: custom sound not playing in FCM push notifications #246

Open husaindevelop opened 2 years ago

husaindevelop commented 2 years ago

We have used your webview project to create our app. Its working great until we hit the roadbloack now we were trying to send a push notification with a custom sound to user's android devices. While sending push notifications using FCM from our app, the message does arrive in user's device but the custom sound set in the payload does not play. The notification arrives,but the custom sound does not play and nor does the default notification sound play. Here is the payload we are using

$notification = [
            'title' =>"Hello",
            'body' =>"Hello",
            'image'=>''
            'sound'=>'https://mbracecloud.com/sound.mp3'
            ];

Firebase.java:NotificationCompat.Builder

Uri soundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, MainActivity.asw_fcm_channel)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setSound(soundUri)
                .setContentIntent(pendingIntent);
        Notification noti = notificationBuilder.build();
        noti.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;

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

        notificationManager.notify(notification_id, notificationBuilder.build());

Do help us out on this issue.

mgks commented 2 years ago

noted, will look into it

husaindevelop commented 2 years ago

Any progress on this issue.