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
IsolatedStorageSave: String Value
IsTrial: ReturnScript
IsolatedStorageGet: String Value : ReturnScript
OnNavigating:ReturnScript *all on navigating events including HTML and app related

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.

Some Tasks have return values. Those include IsTrial, IsolatedStorageGet and Camera. These tasks start in HTML/JScript like any other like this:


Where 'ScriptReturn' is actually the name of a javascript function you want called with the return value like this:

function ScriptReturn(thing) {
JSSource.innerHTML = "ReturnValue: " + thing;

Last edited Nov 9, 2011 at 9:49 PM by DavidKelley, version 2


No comments yet.