通过Cortana发送推送通知

时间:2016-05-20 08:06:29

标签: c# push-notification cortana

我正在用C#编写一个程序来获取系统的公共IP,并告知用户新的IP是否发生变化。问题是我有两种方式通知用户:电子邮件或Cortana。对于第一个(电子邮件),我需要一个我没有的匿名电子邮件发件人,或者要求用户提供他/她的凭据(大多数人不会)。第二种方式(Cortana):假设我在家用电脑上安装了程序,我在Windows 10和带有Cortana的Windows Phone上启用了Cortana。如果家用电脑的公共IP地址发生变化,Cortana将在我的手机上显示通知,包括我的新IP地址。

我在github上看到了一个API(不能这样做)和开发人员的Cortana。我认为“行动”可以完成这项工作,但在阅读完描述后,我肯定不会这样做。

我该怎么做?

我做了什么: 我为Windows 10编写了一个小程序

https://www.microsoft.com/en-us/store/apps/remotecmd/9nblggh4vr31

和服务器端应用

http://naryhd.com/RemoteCMDServerBETA.zip

此应用可让您在Windows手机上安装PC的cmd。 (局部地)

现在我想添加“从互联网访问”,(我这样做了,但出于安全考虑,我禁用了它,现在我得到了一个更安全的解决方案)

我从互联网上访问它有三件事

命令1:

netsh http add urlacl url=http://ip:port/ user=everyone

命令2:

netsh advfirewall firewall add rule name=\"RemoteCMDserver2\" dir=in protocol=tcp localport=port profile=public | private remoteip=localsubnet action=allow

转发该端口:

var discoverer = new NatDiscoverer();
        var cts = new System.Threading.CancellationTokenSource(10000);
        var device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
        await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, port, port, "REMOTECMD"));

我使用nuget的open.nat进行端口转发。

我使用此代码获取PC的公共IP:

var discoverer = new NatDiscoverer();
var device = await discoverer.DiscoverDeviceAsync();
var ip = await device.GetExternalIPAsync();

我将IP保存在文本文件中,并且每分钟重复检查一次,如果更改它将保存该IP并将该IP发送给用户(目前通过电子邮件发送),但我想将其与Cortana一起发送。

1 个答案:

答案 0 :(得分:0)

目前您无法与Cortana合作。您可以在电话上拥有一个应用程序,该应用程序在操作中心或动态磁贴上显示推送通知。

以下是一些有用的链接:

Toast Notification and Action Center Overview for Windows 10

Inside Windows Platform | How to Add Push Notifications to Your App

相关问题