为什么我的消息框出现两次?

时间:2016-07-26 13:50:26

标签: c# xaml push-notification windows-10-universal wns

我正在使用XAML和C#在Windows 10中制作警报应用程序。我正在使用WNS进行推送通知。我写了一个在应用程序中收到通知时触发的函数。这是我的代码:

 private async void Channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
    {
        e.Cancel = true;
        string jsonPayload = "{\"user_id\":\"" + CommonVariables.AuthenticateUserResponseDetails.user.id + "\"}";
        HttpClient client = new HttpClient();
        string postUrl = CommonVariables.SERVER + CommonVariables.Get_Alert;
        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, postUrl);
        //encrypt tase

        EDecrypt encrypt = new EDecrypt();
        jsonPayload = encrypt.AES_Encrypt(jsonPayload, CommonVariables.EncryptionKey);

        request.Content = new StreamContent(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(jsonPayload)));
        var result = await client.SendAsync(request);
        string response = string.Empty;
        response = await result.Content.ReadAsStringAsync();
        EDecrypt edecrypt = new EDecrypt();
        response = edecrypt.AES_Decrypt(response, CommonVariables.EncryptionKey);
        response = response.Replace("\"", "");
        await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
        {
            messageBox(CommonVariables.AuthenticateUserResponseDetails.user.name +  " Please attend " + response + " Theatre");

        });

        ConfirmSeen();

    }

当我收到通知时,消息框会出现两次。我已经尝试将消息框代码放在Dispatcher之外但应用程序错误。我做错了什么?

0 个答案:

没有答案