当前位置:编程学习 > wap >>

Windows Phone 7推送通知服务范例

推送服务端代码:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace PushNotifications_CloudServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] msg = null;
            String type = notificationType.Text;

            switch (type)
            {
                case "Raw":
                    msg = Encoding.UTF8.GetBytes(txtSendMsg.Text);
                    break;
                case "Tile":
                    {
                        string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                                    "<wp:Notification xmlns:wp=\"WPNotification\">" +
                                                                      "<wp:Tile>" +
                                                                        "<wp:BackgroundImage>/Images/Cloudy.png</wp:BackgroundImage>" +
                                                                        "<wp:Count>28</wp:Count>" +
                                                                        "<wp:Title>AnthemSord</wp:Title>" +
                                                                      "</wp:Tile>" +
                                                                    "</wp:Notification>";
                        msg = Encoding.UTF8.GetBytes(tileMessage);
                    }
                    break;
                case "Toast":
                    {
                        string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                                                  "<wp:Notification xmlns:wp=\"WPNotification\">" +
                                                                    "<wp:Toast>" +
                                            &nbs

补充:移动开发 , Windows Phone ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,