如何在Windows Phone

时间:2015-10-05 09:49:05

标签: windows-phone-8

我正在使用openfire和XMPP客户端开发Windows Phone聊天应用程序,我的聊天工作正常,我无法在通知中获取发件人姓名和发件人ID(例如whatsapp) 我正在使用以下代码进行通知

    private void ChannelSetup()
    {
        HttpNotificationChannel httpChn = null;
        string chnName = "Tost";
        httpChn = HttpNotificationChannel.Find(chnName);
        if (httpChn != null)
        {
            if (httpChn.ChannelUri == null)            
{
                httpChn.UnbindToShellToast();
                httpChn.Close();
                ChannelSetup();
                return;
            }

            else
            {

                getChannelURI(httpChn.ChannelUri);

            }

            ShellBinding(httpChn);

        }

        else
        {

            httpChn = new HttpNotificationChannel(chnName);

            httpChn.ChannelUriUpdated += httpChn_ChannelUriUpdated;


            httpChn.ShellToastNotificationReceived += httpChn_ShellToastNotificationReceived;


            httpChn.Open();

            ShellBinding(httpChn);

        }
    }

    private void httpChn_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
    {
        getChannelURI(e.ChannelUri);
    }

    private void httpChn_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
    {
        StringBuilder message = new StringBuilder();
        string relativeUri = string.Empty;

        message.AppendFormat("Received Toast {0}:\n", DateTime.Now.ToShortTimeString());


        foreach (string key in e.Collection.Keys)
        {
            message.AppendFormat("{0}: {1}\n", key, e.Collection[key]);

            if (string.Compare(
                key,
                "wp:Param",
                System.Globalization.CultureInfo.InvariantCulture,
                System.Globalization.CompareOptions.IgnoreCase) == 0)
            {
                relativeUri = e.Collection[key];
            }
        }


    }

0 个答案:

没有答案