Plugin.LocalNotification 10.0.0-preview02

This is a prerelease version of Plugin.LocalNotification.
There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Plugin.LocalNotification --version 10.0.0-preview02
NuGet\Install-Package Plugin.LocalNotification -Version 10.0.0-preview02
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plugin.LocalNotification" Version="10.0.0-preview02" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Plugin.LocalNotification --version 10.0.0-preview02
#r "nuget: Plugin.LocalNotification, 10.0.0-preview02"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Plugin.LocalNotification as a Cake Addin
#addin nuget:?package=Plugin.LocalNotification&version=10.0.0-preview02&prerelease

// Install Plugin.LocalNotification as a Cake Tool
#tool nuget:?package=Plugin.LocalNotification&version=10.0.0-preview02&prerelease

icon64

CI NuGet NuGet

Plugin.LocalNotification

The local notification plugin provides a way to show local notifications from Xamarin.Forms apps.

Setup

Platform Support

Feature Xamarin.iOS Xamarin.Android
Required SDK >= 10 >= API 19
Title
Description
Subtitle
Scheduled
Custom Sounds
Images
Notification Actions
Clear Delivered Notifications
Get Pending Notifications
Get Delivered Notifications

Android Notes:

Project should target Android framework 12.0+

Usage

Show local notification

var notification = new NotificationRequest
{
    NotificationId = 100,
    Title = "Test",
    Description = "Test Description",
    ReturningData = "Dummy data", // Returning data when tapped on notification.
    Schedule = 
    {
        NotifyTime = DateTime.Now.AddSeconds(30) // Used for Scheduling local notification, if not specified notification will show immediately.
    }
};
await NotificationCenter.Current.Show(notification);

Or with Notification Request Builder

await NotificationCenter.Current.Show((notification) => notification                     
			.WithScheduleOptions((schedule) => schedule
					.NotifyAt(DateTime.Now.AddSeconds(30)) // Used for Scheduling local notification, if not specified notification will show immediately.
					.Build())
                        .WithTitle("Test Title")
                        .WithDescription("Test Description")
                        .WithReturningData("Dummy Data") // Returning data when tapped on notification.
                        .WithNotificationId(100)
                        .Create());

With platform specific options

await NotificationCenter.Current.Show((notification) => notification
                    .WithScheduleOptions((schedule) => schedule
					.NotifyAt(DateTime.Now.AddSeconds(30))
					.Build())
                    .WithAndroidOptions((android) => android
                         .WithAutoCancel(true)
                         .WithChannelId("General")
                         .WithPriority(NotificationPriority.High)
                         .WithOngoingStatus(true)
                         .Build())
                    .WithiOSOptions((ios) => ios
                        .WithForegroundAlertStatus(true)
                        .WithForegroundSoundStatus(true)
                        .Build())
                    .WithReturningData("Dummy Data")
                    .WithTitle("Test Title")
                    .WithDescription("Test Description")
                    .WithNotificationId(100)
                    .Create());

Receive local notification tap event

public partial class App : Application
{
	public App()
	{
		InitializeComponent();

		// Local Notification tap event listener
		NotificationCenter.Current.NotificationTapped += OnLocalNotificationTapped;

		MainPage = new MainPage();
	}
	
	private void OnLocalNotificationTapped(NotificationEventArgs e)
    	{
		// your code goes here
	}
}

Notification received event

On iOS this event is fired only when the app is in foreground

public partial class App : Application
{
	public App()
	{
		InitializeComponent();

		// Local Notification received event listener
		NotificationCenter.Current.NotificationReceived += OnLocalNotificationReceived;

		MainPage = new MainPage();
	}
	
	private void OnLocalNotificationReceived(NotificationEventArgs e)
    	{
		// your code goes here
	}
}

Platform Specific Notes

Android

Project should target Android framework 12.0+

image

Setup

To receive Local Notification tap event. Include the following code in the OnNewIntent() method of MainActivity:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
	protected override void OnCreate(Bundle savedInstanceState)
	{
	    	.....
	    	// Must create a Notification Channel when API >= 26
        	// you can created multiple Notification Channels with different names.
        	NotificationCenter.CreateNotificationChannel();		
		.....		
		LoadApplication(new App());
		.....	
		NotificationCenter.NotifyNotificationTapped(Intent);
	}

	protected override void OnNewIntent(Intent intent)
	{
		NotificationCenter.NotifyNotificationTapped(intent);
		base.OnNewIntent(intent);
	}
}

iOS

Setup

You must get permission from the user to allow the app to show local notifications. Also, To receive Local Notification tap event. Include the following code in the FinishedLaunching() method of AppDelegate:

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{        
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            // Ask the user for permission to show notifications on iOS 10.0+ at startup.
            // If not asked at startup, user will be asked when showing the first notification.
            Plugin.LocalNotification.NotificationCenter.AskPermission();

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }

	public override void WillEnterForeground(UIApplication uiApplication)
        {
            Plugin.LocalNotification.NotificationCenter.ResetApplicationIconBadgeNumber(uiApplication);
        }
}

Screen Record

<img src="https://raw.githubusercontent.com/thudugala/Plugin.LocalNotification/60c9342ba866b1af1278c273f3d41a168901e4ff/Screenshots/screenRecord.gif" alt="Screen Record" width="512px" >

Video

Local Push Notifications in Xamarin.Forms

In Visual Studio, confirm that SourceLink is enabled. Also, Turn off "Just My Code" since, well, this isn't your code.

https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/sourcelink

Limitations

Only support <b>iOS</b> and <b>Android</b> for the moment.

Contributing

Contributions are welcome. Feel free to file issues and pull requests on the repo and they'll be reviewed as time permits.

Thank you

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-android31.0 is compatible.  net6.0-ios was computed.  net6.0-ios15.2 is compatible.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed.  monoandroid10.0 is compatible. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed.  xamarinios10 is compatible. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Plugin.LocalNotification:

Package Downloads
Fluker

This package contains common classes and interfaces that are used in other Fluker controls.

Fluker.Media

This package contains classes, interfaces, controls and utility for support media like video, pdf and images in the app. It depends on Fluker

Fluker.Maps

This package contains support to custom integrations of the system Map platform. It depends on Fluker.Base

Fluker.Account.Email

This package contains classes, interfaces, controls and utility for support Users (Login, Registrarion) through email in the app. It depends on Fluker

Fluker.Shop.Stripe

This package contains classes, interfaces, controls and utility for integrate a shop system like cart and payments with credit card in the app. It depends on Fluker.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Plugin.LocalNotification:

Repository Stars
msasanmh/SecureDNSClient
A DNS Client Supporting DNSCrypt, DoH, DoT, UDP And TCP.
thudugala/Plugin.LocalNotification
The local notification plugin provides a way to show local notifications from .Net MAUI and Xamarin Forms apps .
Version Downloads Last updated
11.1.2 418 4/14/2024
11.1.1 3,753 2/26/2024
11.1.0 1,439 2/21/2024
10.2.0-preview01 124 2/21/2024
10.1.8 53,829 6/29/2023
9.2.0 39,993 2/8/2022
8.0.2 7,306 7/21/2021
7.0.0 1,337 7/17/2021
6.1.0 25,375 6/3/2021
5.2.0 27,269 12/17/2020