Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ A consistent and easy way to show local notifications in Xamarin and Windows app
|Windows Store (WinRT)|Yes|8.1+|
|Windows (UWP)|Yes|10+|
|Xamarin.Mac|No||
|Tizen|Yes|4.0+|

### API Usage

Expand Down
4 changes: 4 additions & 0 deletions nuget/Plugin.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<file src="src\Plugin.LocalNotifications.iOS\bin\iPhoneSimulator\Release\Plugin.LocalNotifications.xml" target="lib\Xamarin.iOS10\Plugin.LocalNotifications.xml" />
<file src="src\Plugin.LocalNotifications.Abstractions\bin\Release\Plugin.LocalNotifications.Abstractions.dll" target="lib\Xamarin.iOS10\Plugin.LocalNotifications.Abstractions.dll" />
<file src="src\Plugin.LocalNotifications.Abstractions\bin\Release\Plugin.LocalNotifications.Abstractions.xml" target="lib\Xamarin.iOS10\Plugin.LocalNotifications.Abstractions.xml" />

<!--Tizen-->
<file src="src\Plugin.LocalNotifications.Tizen\bin\Release\tizen40\Plugin.LocalNotifications.dll" target="lib\tizen40\Plugin.LocalNotifications.dll" />
<file src="src\Plugin.LocalNotifications.Abstractions\bin\Release\tizen40\Plugin.LocalNotifications.Abstractions.dll" target="lib\tizen40\Plugin.LocalNotifications.Abstractions.dll" />

</files>
</package>
57 changes: 55 additions & 2 deletions src/LocalNotifications.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.LocalNotifications.Abstractions", "Plugin.LocalNotifications.Abstractions\Plugin.LocalNotifications.Abstractions.csproj", "{57564CE6-C079-47C5-9272-4395A0224C3D}"
EndProject
Expand All @@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.LocalNotifications.W
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.LocalNotifications.macOS", "Plugin.LocalNotifications.macOS\Plugin.LocalNotifications.macOS.csproj", "{1F3C7F03-BCEB-46E7-B9B8-843D4DEF7364}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.LocalNotifications.Tizen", "Plugin.LocalNotifications.Tizen\Plugin.LocalNotifications.Tizen.csproj", "{4A54649B-003D-473C-B194-4DF8DDEA5589}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down Expand Up @@ -415,8 +417,59 @@ Global
{1F3C7F03-BCEB-46E7-B9B8-843D4DEF7364}.Release|x64.Build.0 = Release|Any CPU
{1F3C7F03-BCEB-46E7-B9B8-843D4DEF7364}.Release|x86.ActiveCfg = Release|Any CPU
{1F3C7F03-BCEB-46E7-B9B8-843D4DEF7364}.Release|x86.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|ARM.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|iPhone.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|x64.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|x64.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|x86.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.AppStore|x86.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|ARM.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|ARM.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|iPhone.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|x64.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|x64.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Debug|x86.Build.0 = Debug|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|Any CPU.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|ARM.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|ARM.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|iPhone.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|iPhone.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|x64.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|x64.Build.0 = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|x86.ActiveCfg = Release|Any CPU
{4A54649B-003D-473C-B194-4DF8DDEA5589}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CFD1968F-13AE-4B7D-A1ED-01833C6F48C4}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using Plugin.LocalNotifications.Abstractions;
using Tizen.Applications.Notifications;
using System.Timers;

namespace Plugin.LocalNotifications
{
/// <summary>
/// Local Notifications implementation for Tizen
/// </summary>
public class LocalNotificationsImplementation : ILocalNotifications
{
Timer timer;
int notificationId = 0;
/// <summary>
/// Show a local notification
/// </summary>
/// <param name="title">Title of the notification</param>
/// <param name="body">Body or description of the notification</param>
/// <param name="id">Id of the notification</param>
public void Show(string title, string body, int id = 0)
{
Notification notification = new Notification
{
Title = title,
Content = body,
Tag = id.ToString(),
};
Notification.IndicatorStyle style = new Notification.IndicatorStyle
{
SubText = body
};
notification.AddStyle(style);
NotificationManager.Post(notification);
}

/// <summary>
/// Show a local notification at a specified time
/// </summary>
/// <param name="title">Title of the notification</param>
/// <param name="body">Body or description of the notification</param>
/// <param name="id">Id of the notification</param>
/// <param name="notifyTime">Time to show notification</param>
public void Show(string title, string body, int id, DateTime notifyTime)
{
Notification notification = new Notification
{
Title = title,
Content = body,
Tag = id.ToString(),
};
notificationId = id;
Notification.IndicatorStyle style = new Notification.IndicatorStyle
{
SubText = body
};
notification.AddStyle(style);
NotificationManager.Post(notification);

var time = notifyTime - DateTime.Now;
int duration = (time.Seconds + time.Milliseconds / 1000);

timer = new Timer();
timer.Interval = duration * 1000;
timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
timer.Start();
}

void TimerElapsed(object sender, ElapsedEventArgs e)
{
Cancel(notificationId);
timer.Stop();
}

/// <summary>
/// Cancel a local notification
/// </summary>
/// <param name="id">Id of the notification to cancel</param>
public void Cancel(int id)
{
Notification loadNotification = null;
try
{
loadNotification = NotificationManager.Load(id.ToString());
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
if (loadNotification != null)
NotificationManager.Delete(loadNotification);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- Property Group for Tizen Project -->
<PropertyGroup>
<TargetFramework>tizen40</TargetFramework>
<TizenCreateTpkOnBuild>false</TizenCreateTpkOnBuild>
<AssemblyName>Plugin.LocalNotifications</AssemblyName>
<RootNamespace>Plugin.LocalNotifications</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>None</DebugType>
</PropertyGroup>

<!-- Include Nuget Package for Tizen Project building -->
<ItemGroup>
<PackageReference Include="Tizen.NET" Version="4.0.0">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Plugin.LocalNotifications\CrossLocalNotifications.cs">
<Link>CrossLocalNotifications.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Plugin.LocalNotifications.Abstractions\Plugin.LocalNotifications.Abstractions.csproj">
<Project>{57564CE6-C079-47C5-9272-4395A0224C3D}</Project>
<Name>Plugin.LocalNotifications.Abstractions</Name>
</ProjectReference>
</ItemGroup>

</Project>