繁体   English   中英

Cordova WP8-推送通知回调

[英]Cordova WP8 - Push Notifications Callback

似乎没有方法在关闭应用程序时触发“功能”,而在未打开应用程序时通过“ 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目前尚未完全加载,并且实际上并未在应用程序端触发该功能。 有什么我可以“强制”执行此操作以等待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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM