Wednesday, June 15, 2011

Using HTML App Host Tasks from the ECMA Script Context

Using the task framework ( and the taskprocessor are pretty easy. Basically it needs to look like this:

window.external.notify(" from JavaScriptFWP7");

the format for calls are:

window.external.notify(" Task Name : Paramter1 : Parameter2 : etc ");

the current supported tasks include:

Email : To Email : Subject
SystemTray : Boolean Value
EnableFrameRateCounter : Boolean Value
alert : message value : message box title
play : sound uri path
vibrate : hours : minutes : seconds
MarketplaceSearchTask : app id
Analytics : Parmeters * n
MarketplaceDetailTask : app id
WebBrowserTask : URL String

There is also a custom event on the AppHostShell called ScriptNotify that allows you to extend what you can do with tasks for example in the code base the sample app does this extension from the custom event:

private void webBrowser1_ScriptNotify(object sender, NotifyEventArgs e)
switch (e.Value.ToString())
case "task1":
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "";
emailComposeTask.Body = "";
emailComposeTask.Subject = "Email from JSWP7";
case "task2":
NavigationService.Navigate(new Uri("/About.xaml", UriKind.Relative));


this gets around a limition with calling the navigation service that I'm currently working on.

No comments:

Post a Comment