diff --git a/plugin.xml b/plugin.xml index da4ee66..5acc9f8 100755 --- a/plugin.xml +++ b/plugin.xml @@ -50,4 +50,15 @@ + + diff --git a/src/wp8/Toast.cs b/src/wp8/Toast.cs new file mode 100644 index 0000000..c38c602 --- /dev/null +++ b/src/wp8/Toast.cs @@ -0,0 +1,34 @@ +using WPCordovaClassLib.Cordova; +using WPCordovaClassLib.Cordova.Commands; +using WPCordovaClassLib.Cordova.JSON; + +// TODO create a custom overlay similar to the iOS implementation because the ShellToast on WP is +// very different from the native Android Toast the iOS impl is inspired on. +// Differences: +// - Only WP8 update 3 will show a Toast when in the foreground +// - A ShellToast can't be positioned +// - A ShellToast has a fixed duration +// DOCS: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662938(v=vs.105).aspx +// --> Conclusion: ShellToast is more like a localnotification/pushmessage, so it's a nice WP8 impl of the LocalNotification plugin, +// So we'll only add WP8 Toast plugin support if we can create an similar impl as the iOS version of this Toast plugin. +// Hence, leaving out the WP8 config in plugin.xml for now. +namespace Cordova.Extension.Commands { + public class Toast : BaseCommand { + + public void show(string jsonArgs) { + + var options = JsonHelper.Deserialize(jsonArgs); + + var message = options[0]; +// var duration = options[1]; +// var position = options[2]; + + ShellToast toast = new ShellToast(); + toast.Title = "Test"; + toast.Content = message; + toast.Show(); + + DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); + } + } +} \ No newline at end of file