Commit 94eaef3e by Sebastián Katzer

Basic WP8 support through LiveTiles

parent 24360db0
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<config-file target="config.xml" parent="/*"> <config-file target="config.xml" parent="/*">
<feature name="LocalNotification"> <feature name="LocalNotification">
<param name="wp-package" value="LocalNotification"/> <param name="wp-package" value="LocalNotification"/>
<param name="wp-package" value="LocalNotificationOptions"/>
</feature> </feature>
</config-file> </config-file>
......
...@@ -16,10 +16,91 @@ using WPCordovaClassLib.Cordova; ...@@ -16,10 +16,91 @@ using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands; using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON; using WPCordovaClassLib.Cordova.JSON;
using De.APPPlant.Cordova.Plugin.LocalNotification;
namespace Cordova.Extension.Commands namespace Cordova.Extension.Commands
{ {
/// <summary>
/// Implementes access to application live tiles
/// http://msdn.microsoft.com/en-us/library/hh202948(v=VS.92).aspx
/// </summary>
public class LocalNotification : BaseCommand public class LocalNotification : BaseCommand
{ {
/// <summary>
/// Sets application live tile
/// </summary>
public void add (string jsonArgs)
{
string[] args = JsonHelper.Deserialize<string[]>(jsonArgs);
LocalNotificationOptions options = JsonHelper.Deserialize<LocalNotificationOptions>(args[0]);
// Application Tile is always the first Tile, even if it is not pinned to Start.
ShellTile AppTile = ShellTile.ActiveTiles.First();
if (AppTile != null)
{
// Set the properties to update for the Application Tile
// Empty strings for the text values and URIs will result in the property being cleared.
StandardTileData TileData = CreateTileData(options);
// Update the Application Tile
AppTile.Update(TileData);
}
DispatchCommandResult();
}
/// <summary>
/// Clears the application live tile
/// </summary>
public void cancel (string jsonArgs)
{
cancelAll(jsonArgs);
}
/// <summary>
/// Clears the application live tile
/// </summary>
public void cancelAll (string jsonArgs)
{
// Application Tile is always the first Tile, even if it is not pinned to Start.
ShellTile AppTile = ShellTile.ActiveTiles.First();
if (AppTile != null)
{
// Set the properties to update for the Application Tile
// Empty strings for the text values and URIs will result in the property being cleared.
StandardTileData TileData = new StandardTileData
{
Title = "",
BackTitle = "",
BackContent = ""
};
// Update the Application Tile
AppTile.Update(TileData);
}
DispatchCommandResult();
}
/// <summary>
/// Creates tile data
/// </summary>
private StandardTileData CreateTileData (LocalNotificationOptions options)
{
StandardTileData tile = new StandardTileData();
// Badge sollte nur gelöscht werden, wenn expliziet eine `0` angegeben wurde
if (options.Badge != 0)
{
tile.Count = options.Badge;
}
tile.BackTitle = options.Title;
tile.Title = options.Title;
tile.BackContent = options.Message;
return tile;
}
} }
} }
using System.Runtime.Serialization;
namespace De.APPPlant.Cordova.Plugin.LocalNotification
{
/// <summary>
/// Represents LiveTile options
/// </summary>
[DataContract]
class LocalNotificationOptions
{
/// <summary>
/// The Title that is displayed
/// </summary>
[DataMember(IsRequired = false, Name = "title")]
public string Title { get; set; }
/// <summary>
/// The message that is displayed
/// </summary>
[DataMember(IsRequired = false, Name = "message")]
public string Message { get; set; }
/// <summary>
/// Displays number badge to notification
/// </summary>
[DataMember(IsRequired = false, Name = "badge")]
public int Badge { get; set; }
/// <summary>
/// Tile count
/// </summary>
[DataMember(IsRequired = false, Name = "Date")]
public int Date { get; set; }
/// <summary>
/// Has the options of daily', 'weekly',''monthly','yearly')
/// </summary>
[DataMember(IsRequired = false, Name = "repeat")]
public string Repeat { get; set; }
/// <summary>
/// Message-ID
/// </summary>
[DataMember(IsRequired = false, Name = "id")]
public string ID { get; set; }
/// <summary>
/// A javascript function to be called if the app is in the background
/// </summary>
[DataMember(IsRequired = false, Name = "background")]
public string Background { get; set; }
/// <summary>
/// A javascript function to be called if the app is running
/// </summary>
[DataMember(IsRequired = false, Name = "foreground")]
public string Foreground { get; set; }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment