A consistent and easy way to show local notifications in Zebble apps.
With local notifications, your app configures the notification details locally and passes those details to the system, which then handles the delivery of the notification when your app is not in the foreground. Local notifications are supported on iOS, Android and UWP.
- Available on NuGet: https://www.nuget.org/packages/Zebble.LocalNotification/
- Install in your platform client projects.
- Available for iOS, Android and UWP.
Call Zebble.Device.LocalNotification
from any project to gain access to APIs.
await LocalNotification.Show("Test", "This is the body message");
await LocalNotification.Schedule("Test", "This is the body message", DateTime.Now.AddSeconds(30), 1);
Some platforms require certain permissions or settings before it will display notifications.
In android project of Zebble application you should call Initialize method in OnCreate method of MainActivity class like below code:
await LocalNotification.Initialize(Intent);
So, your MainActivity will look like this:
protected override async void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
await LocalNotification.Initialize(Intent);
Setup.Start(FindViewById<FrameLayout>(Resource.Id.Main_Layout),this).RunInParallel();
await (StartUp.Current = new UI.StartUp()).Run();
}
�
Call Initialize method of LocalNotification in FinishedLaunching method of AppDelegate class:
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
var result = base.FinishedLaunching(application, launchOptions);
LocalNotification.Initialize(launchOptions);
return result;
}
Event | Type | Android | iOS | Windows |
---|---|---|---|---|
Tapped | AsyncEvent<KeyValuePair<string, string>[]> | x | x | x |
Method | Return Type | Parameters | Android | iOS | Windows |
---|---|---|---|---|---|
Show | Task<bool> | title -> string body -> string |
x | x | x |
Schedule | Task<bool> | title -> string body -> string notifyTime -> DateTime id -> int |
x | x | x |
Cancel | Task | id -> int | x | x | x |
Initialize | Task | options -> object | x | x | x |