I have an app in xamarin ios in which I want to play alarm tone when notification fires and stop when user dismiss the notification. How can I achieve this ?
I have an app in xamarin ios in which I want to play alarm tone when notification fires and stop when user dismiss the notification. How can I achieve this ?
Take a look at UNNotificationSound , it is used to customize sound played upon delivery of a notification.
For local notifications, assign the sound object to the sound property of your UNMutableNotificationContent object.
var content = new UNMutableNotificationContent();
content.Title = "Title";
content.Sound = UNNotificationSound.GetCriticalSound("a.aiff");
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(5, false);
var request = UNNotificationRequest.FromIdentifier("a", content,trigger);
UNUserNotificationCenter.Current.AddNotificationRequest(request, null);
Place the sound file in the following locations :
The sound must be in one of the following audio data formats:
Linear PCM
MA4 (IMA/ADPCM)
µLaw
aLaw
You can package the audio data in an aiff, wav, or caf file.
Sound files must be less than 30 seconds in length.
If the sound file is longer than 30 seconds, the system plays the default sound instead.