Skip to content

Latest commit

 

History

History
96 lines (65 loc) · 2.85 KB

README.md

File metadata and controls

96 lines (65 loc) · 2.85 KB

ACR Notifications Plugin for Xamarin and Windows

Plugin for Easy Cross Platform notifications

NuGet Change Log - July 28, 2017

Features

  • Local Notifications
  • Scheduled Notifications
  • Sounds
  • Read all Scheduled Notifications
  • Badges
  • Set metadata on each notification for identification
  • Cancel individual or all notifications

Supported OS

  • iOS 6+
  • macOS
  • Android 4+
  • Universal Windows Platform (Win10/UWP)
  • NET Standard 1.0

Installation

Install the nuget package in your platform project as well as your netstandard library.

Send a notification

await CrossNotifications.Current.Send("My Title", "My message for the notification");

Send a scheduled notification:

await CrossNotifications.Current.Send("Happy Birthday", "I sent this a long time ago", when = TimeSpan.FromDays(50));

Get a list of scheduled notifications

var list = await CrossNotifications.Current.GetScheduledNotifications();

Cancel a specific notification

var id = await CrossNotifications.Current.Send("Hi", "This is my scheduled notification", when = TimeSpan.FromDays(1));
await CrossNotifications.Current.Cancel(id);

Cancel all scheduled notifications and clear badge:

CrossNotifications.Current.CancelAll();

To set a badge:

Setting badges works on all platforms, though only select flavours of Android. A 3rd party library is used to accomplish this.

await CrossNotifications.Current.SetBadge(4);
await CrossNotifications.Current.GetBadge();
// 0 clears badge

Sounds

In the notification.Sound property - set only the filename without the extension

Android

  • Put the sound in your /Resources/raw/ folder - make sure the file properties is set to AndroidResource
  • You can pass the actual full sound path OR just the name... the plugin will figure it out!

iOS

  • Put the file in your iOS app bundle
  • The file format must be a .caf file (google this to see how to make one) - ie. afconvert -f caff -d aacl@22050 -c 1 sound.aiff soundFileName.caf

UWP

FAQ

  • Why are most methods async now?

  • iOS requires all UI based commands run on the UI thread. Notifications are part of UIKit and thus have this requirement. With all of my plugins, I try to manage the thread marshalling for you

  • Why can't I set a string as an identifier

  • Android needs an integer for how it sets identifiers