예제 #1
0
        protected void btn_Send_Click(object sender, EventArgs e)
        {
            JPushClient pushClient = new JPushClient(apikKey, secretKey);
            try
            {
                Message msg = new Message(txtContent.Value, txtTitle.Value, "");

                //广播
                if (this.rbBrandCast.Checked)
                {
                    pushClient.SendPush(PushPayload.SendAndroidAlertPushToAll(msg));
                }
                //批量发送
                else if (this.rbBatch.Checked)
                {
                    string[] paramsId = new string[] { "0304819befc", "021032" };
                    pushClient.SendPush(PushPayload.SendAndroidAlertBatchPush(msg, paramsId));
                }
                //单独设备发送
                else if (rbSingleDevice.Checked)
                {
                    string registerId = "0304819befc";
                    pushClient.SendPush(PushPayload.SendAndroidAlertSinglePush(msg, registerId));

                }
            }
            catch (Exception msg)
            {
                txtResponse.Value = msg.Message;
            }
        }
예제 #2
0
        public PushPayload(Platform platform, Audience audience, Message message , Options options = null)
        {
            Debug.Assert(platform != null);
            Debug.Assert(audience != null);
            Debug.Assert(message != null);

            this.platform = platform;
            this.audience = audience;
            this.message = message;
            this.options = options;

            jSetting = new JsonSerializerSettings();
            jSetting.NullValueHandling = NullValueHandling.Ignore;
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
        }
예제 #3
0
        public PushPayload(Platform platform, Audience audience, Notification notification, Message message = null, SmsMessage sms_message = null, Options options = null)
        {
            Debug.Assert(platform != null);
            Debug.Assert(audience != null);
            Debug.Assert(notification != null || message != null);

            this.platform = platform;
            this.audience = audience;
            this.notification = notification;
            this.message = message;
            this.sms_message = sms_message;
            this.options = options;

            jSetting = new JsonSerializerSettings();
            jSetting.NullValueHandling = NullValueHandling.Ignore;
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
        }
예제 #4
0
 /// <summary>
 /// 按照设备号发送 android  单设备
 /// </summary>
 /// <param name="message"></param>
 /// <param name="registerId"></param>
 /// <returns></returns>
 public static PushPayload SendAndroidAlertSinglePush(Message message, string registerId)
 {
     return new PushPayload(Platform.android(),
                            Audience.s_registrationId(registerId),
                            Notification.android(message.msg_content, message.title),
                            null,
                            new Options());
 }
예제 #5
0
 /// <summary>
 /// 安卓端广播
 /// </summary>
 /// <param name="alert"></param>
 /// <returns></returns>
 public static PushPayload SendAndroidAlertPushToAll(Message message)
 {
     return new PushPayload(Platform.android(),
                            Audience.all(),
                             Notification.android(message.msg_content, message.title),
                            null,
                            new Options());
 }