我正在构建一个与解析服务器连接的Windows Phone应用程序我想知道我是否可以接收来自服务器的推送通知(我从服务器发送通知但我没有收到它并且服务器连接正常,因为我可以发送对象,服务器完美地接收它们。我做了很多研究,我找到了一段代码,但我不知道把它放在哪里所以我把它放在按钮点击这样:
private async void Button_Click_3(object sender, RoutedEventArgs e)
{
try
{
var installation = ParseInstallation.CurrentInstallation;
installation.AddUniqueToList("channels", "Giants");
await installation.SaveAsync();
MessageBox.Show("Done ! ");
ParsePush.ToastNotificationReceived += ParsePushOnToastNotificationReceived;
await ParseAnalytics.TrackAppOpenedAsync();
MessageBox.Show("Done ! ");
}
catch (Exception ex)
{
}
}
void ParsePushOnToastNotificationReceived(object sender, NotificationEventArgs notificationEventArgs)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// do anything
MessageBox.Show("got notification");
});
}