среда, 26 октября 2011 г.

Processing msApplication-Arguments

Developers can build the best experience for consumers by ensuring that the switch from the site to the app is contextual. For example, in the above video, when the user switches to the app while reading a review of a phone on the Web site, the app automatically navigates the user to the phone review within the app. This provides users with a continuous experience from the site to the app.
msApplication-Arguments enables this. The content string of this meta tag is passed to the app as an argument string. The app parses this parameter and navigates users to the relevant in-app content.
The following code fragment shows how to handle this parameter in a Metro style app written in HTML/JavaScript:
// Function available in default.js file in Visual Studio Express 11 templates provided in Developer Preview Build
WinJS.Application.onmainwindowactivated = function (e) {
if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
// Insert this code to handle incoming argument when Metro style Internet Explorer launches the app
if (e.detail.arguments) {
// Parse the value of the msApplication-Arguments string
// Direct incoming user to relevant in-app content
}
}
}
This fragment could be used in a Metro style app written in XAML/C#
// Function available in App.xaml.js file in Visual C# templates provided in Developer Preview Build Visual Studio Express 11
partial class App
{
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
// Insert this to handle incoming arguments, when Metro Style Internet Explorer launches the app
if (!String.IsNullOrEmpty(args.Arguments))
{
// Parse the value of the msApplication-Arguments string
// Direct incoming user to relevant in-app content
}
}
}

Conclusion

Metro style Internet Explorer lets users discover and experience the Web through associated Metro style apps. It enables Web developers to drive their existing site audience to their apps, giving them new opportunities to engage their users with an immersive experience on Windows 8

Комментариев нет:

Отправить комментарий