- Home /
Question by
Timberoth · May 29, 2015 at 05:41 AM ·
iossoundlocalnotification
iOS Local Notification doesn't make a sound
I've been able to get the basic iOS Local Notifications working, but for some reason the default alert sound will not play when the notification is received. I'm not customizing the sound so I should hear the default sound, but currently hear nothing. I double checked that my App's settings have Notifications enabled and Sound enabled.
Am I missing a step in the process or am I not registering for sound notifications properly?
void Start () {
// Unity Local Notifications are only support on iOS
if (Application.platform == RuntimePlatform.IPhonePlayer) {
NotificationServices.RegisterForLocalNotificationTypes (LocalNotificationType.Alert | LocalNotificationType.Badge | LocalNotificationType.Sound);
// Test notification
LocalNotification notification = new LocalNotification ();
notification.alertBody = "Hello World";
notification.alertAction = "Alert Action";
notification.hasAction = true;
notification.applicationIconBadgeNumber = -1;
notification.fireDate = DateTime.Now.AddSeconds (10);
Dictionary<string,string> customData = new Dictionary<string, string> ();
customData.Add ("gem_bonus", "2");
customData.Add ("coin_bonus", "3");
notification.userInfo = customData;
NotificationServices.ScheduleLocalNotification (notification);
StartCoroutine (ReceiveLocalNotifications ());
}
}
Comment
Answer by andrew-fray · Jun 16, 2015 at 01:14 PM
The sound setting of the local notification object doesn't seem to include the default sound by default! Try this:
notification.soundName = LocalNotification.defaultSoundName;
...then it worked for me.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200347im_/https://answers.unity.com/themes/thub/images/avi.jpg)