- Local Notifications
- Sounds
- Scheduled Notifications
- Badges
- iOS 6+
- Android 4+
- Universal Windows Platform (Win10/UWP)
- Portable Class Libraries (Profile 259)
Install the nuget package in your platform project as well as your shared library.
CrossNotifications.Current.Send("My Title", "My message for the notification");
CrossNotifications.Current.Send("Happy Birthday", "I sent this a long time ago", when = TimeSpan.FromDays(50));
var id = CrossNotifications.Current.Send("Hi", "This is my scheduled notification", when = TimeSpan.FromDays(1));
CrossNotifications.Current.Cancel(id);
[warning] This will not cancel future scheduled notifications on Android. Keep the notification IDs and cancel one-by-one
CrossNotifications.Current.CancelAll();
Badges work on iOS and Windows, but only certain flavours of Android. Please take a Xamarin.ShortcutBadger for more info.
CrossNotifications.Current.Badge = 4; // TODO: 0 clears badge
This library only forwards a path through to the native API. These paths will be vastly different between platforms
You can set a default sound:
Notification.DefaultSound = "path";
The path will be something like android.resource://!YOUR PACKAGE NAME!/raw/"; Go to https://stackoverflow.com/questions/13760168/how-to-set-notification-with-custom-sound-in-android for more info Make sure the file is set as an AndroidResource in its file properties.
You must simply add a caf sound to the app bundle and call it with notification.Sound = "soundname.caf";