Cordova WP8 - 推送通知回调

Cordova WP8 - Push Notifications Callback

似乎没有办法在应用程序关闭时触发 "function" 并且在应用程序打开时通过 "Toast" 导航到。我知道你可以这样做:

 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            try
            {
                if (this.NavigationContext.QueryString["NavigatedFrom"] == "toast") // this is set on the server
                {
                    this.CordovaView.StartPageUri = new Uri("//www/index.html#notification-page", UriKind.Relative);




                }
            }
            catch (KeyNotFoundException)
            {
            }
        }

问题是这会触发应用程序重新加载并且所有本地存储都丢失。我们不能使用查询字符串,因为它会在应用加载时引发错误。

我想尝试在回调中做这样的事情:

 this.CordovaView.CordovaBrowser.InvokeScript("eval", new string[] { // some script here to callback to the JS level });

但是此时 CordovaView 似乎没有完全加载,实际上并没有在应用程序端触发该功能。我可以做些什么来 "force" 等待 Cordova 在它触发之前完全加载吗?

只需添加一个额外的包装器即可:

this.CordovaView.CordovaBrowser.InvokeScript("eval", new string[] { 
"document.addEventListener('deviceready',function(){/*some script here to callback to the JS level*/ });"
});

==更新

以上没有完全按预期工作,因为在这种情况下,事件甚至在 CordovaBrowser 页面加载之前就已触发。 JIRA 问题在这里:https://issues.apache.org/jira/browse/CB-8776