先添加这个插件https://github.com/phonegap-build/PushPlugin
将此添加到脚本文件中。
if(deviceID == "undefined" || deviceID == null || deviceID == "null"){
pushNotificationVariable = window.plugins.pushNotification;
var platform = device.platform;
switch(platform){
case 'iOS':
pushNotificationVariable.register(tokenHandler,errorHandler,{ "badge":"true","sound":"true","alert":"true","ecb":"onNotificationAPN"});
break;
case 'Android':
pushNotificationVariable.register(successHandler,errorHandler,{"senderID":"643203326229","ecb":"onNotification"});
break;
case 'Win32NT':
var channelName = "PUSHChannel";
pushNotificationVariable.register(channelHandler, errorHandler, { "channelName": channelName, "ecb": "onNotificationWP8", "uccb": "channelUriHandler", "errcb": "jsonErrorHandler" });
break;
default:
window.localStorage.setItem("DeviceID",device.uuid);
break;
}
}
此代码将在您将该 ChannelURI 发送到 Service 之后返回 ChannelURI,以便他们能够将 Push 发送到 windows phone。
Try this
Reference
在 Mainpage.xaml.cs 中添加这个
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
try
{
if (this.NavigationContext.QueryString["NavigatedFrom"] == "Toast Notification") // this is set on the server
{
string navigatedString = this.NavigationContext.QueryString["NavigatedFrom"];
this.CordovaView.StartPageUri = new Uri("//www/index.html#navstring=" + navigatedString, UriKind.Relative);
}
}
catch (KeyNotFoundException)
{
}
}
从 javscript 调用 angularjs 函数
function ajaxResultPost(data, type, res) {
var scope = angular.element(document.getElementById("MainWrap")).scope();
scope.$apply(function () {
scope.updateCustomRequest(data, type, res);
});
}
如果你想从 c# 调用 javascript 函数,那么试试这个
this.CordovaView.Browser.InvokeScript("eval", new string[] { "yourJavascriptFunction(); " });
如何从 C# 调用 JavaScript – Cordova/PhoneGap
https://cordovablogsblogs.wordpress.com/2015/07/10/how-to-call-javascript-from-c-cordovaphonegap/