Bug 259 - UILocalNotification.SoundName
Summary: UILocalNotification.SoundName
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2011-08-10 17:27 UTC by ric3kg
Modified: 2011-08-10 21:17 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

sound file (31.38 KB, audio/aiff)
2011-08-10 17:27 UTC, ric3kg

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description ric3kg 2011-08-10 17:27:40 UTC
Created attachment 107 [details]
sound file

The following code does not add the custom sound to the LocalNotification:

string audioFilePath = Path.Combine(Environment.CurrentDirectory, "swannee.aif");
localNote.SoundName = audioFilePath;

When it fires an error is returned stating that the file cannot be found. Examining the bundle, the file is there...
Comment 2 Sebastien Pouliot 2011-08-10 21:17:05 UTC
Hello Rick,

You did not supply a full test case so I cannot tell you exactly what's wrong with your code. However here's how I got this to work.

a) first make sure that your .aif file is added as "Content" into your project (in MD, right click on your solution, select "Build Action" menu and select "Content". Otherwise the file won't be inside included properly into the bundle.

b) there's the code I used:

		public void LocalNotification ()
			UILocalNotification n = new UILocalNotification ();
			// the current directory is already set to the bundle directory
			n.SoundName = "swannee_original.aif";
			n.AlertBody = "body";
			n.AlertAction = "action";
			n.ApplicationIconBadgeNumber = 42;
			n.FireDate = NSDate.Now.AddSeconds (30);
			n.TimeZone = NSTimeZone.DefaultTimeZone;
			UIApplication.SharedApplication.ScheduleLocalNotification (n);

and called the method from FinishedLaunching

c) I statred the app in the simulator, hit the home button (so it went on the background) and waited 30 seconds.

d) I got the notification plaing your sound