Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Strange behaviour, custom notification sound played only in background

$
0
0

Hi

I have a strange problem. I want to play notification sounds when app is active, and when in background too, but now, i dont know why the custom sounds played only when app is in background.

Here is my code

 var content = new UNMutableNotificationContent
            {
                Title = title,
                Subtitle = "",
                Body = message
            };

            if (!string.IsNullOrEmpty(soundFileName))
                content.Sound = UNNotificationSound.GetSound(soundFileName);

            var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(0.01, false);

            var request = UNNotificationRequest.FromIdentifier(messageId.ToString(), content, trigger);
            UNUserNotificationCenter.Current.AddNotificationRequest(request, err =>
            {
                if (err != null) throw new Exception($"Failed to schedule notification: {err}");
            });

What can i do to play sounds always?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>