示例#1
0
        protected string GcmPushNotificationfn(string waiterId, string msg, string restId, string tableNum)
        {
            //this.SpName = "DigitalMenu_GetGCMRegId"; //Sp Name

            this.SpName = "[DigitalMenu_GetGCM_RegID]";
            try
            {
                SqlParameter[] param = new SqlParameter[2];
                param[0] = new SqlParameter("@WaitorId", waiterId);
                param[1] = new SqlParameter("@RestId", int.Parse(restId));
                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    DataRowCollection drc = ds.Tables[0].Rows;
                    foreach (DataRow item in drc)
                    {
                        RegId = "" + item["RegID"].ToString();

                    }

                    AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification();
                    string deviceId = RegId;
                    //   string deviceId = "APA91bFKgxQBZve4dlbt-x20GE45PI9FyH3O3r80CwGpsZu3K3wem860wg4rHtf35hc3v-v4zyoyUSKCzNgce-fKTKE-is3nixMyMTxWW5TRwvnxc5ukvX51sySYeZ5kiEKR84uqq-Z_";
                    string message = msg;
                    string tickerText = tableNum; //"example test GCM";
                    string contentTitle = "content title GCM";
                    string ApiKey = "AIzaSyCclEA_Gbb70InvtsV9CXPQLGRjVesl1NA";// -- jaydev
                    // string ApiKey = "AIzaSyDFky610kEk8Q8crJqSvJgs9GhI60jvdFs";
                    string postData =
                    "{ \"registration_ids\": [ \"" + deviceId + "\" ], " +
                      "\"data\": {\"tickerText\":\"" + tickerText + "\", " +
                                 "\"contentTitle\":\"" + contentTitle + "\", " +
                                 "\"message\": \"" + message + "\"}}";

                    string response = apnGCM.SendGCMNotification(ApiKey, postData);

                    if (response == "error")
                    {
                        return "2";

                    }
                    else
                    {

                        string[] x = response.Split(',');
                        string success = x[1].Split(':')[1];
                        if (success == "1")
                        {
                            return "1";

                        }

                    }

                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(LogLevelL4N.ERROR, " Unable To Send Notification: | Exception : " + ex.Message);
            }

            return "2";
        }
示例#2
0
        protected void NotifyCheckout(RP_CustomerCheckout rpCustomerCheckout)
        {
            this.SpName = "DigitalMenu_GetGCMRegId"; //Sp Name
            try
            {
                SqlParameter[] param = new SqlParameter[2];
                param[0] = new SqlParameter("@WaitorId", rpCustomerCheckout.WaiterId);
                param[1] = new SqlParameter("@RestId", int.Parse(rpCustomerCheckout.RestId));
                // param[2] = new SqlParameter("@TableId", rpCustomerCheckout.TableId);

                ds = db.GetDataSet(this.SpName, param);
                if (ds != null && ds.Tables.Count > 0)
                {
                    DataRowCollection drc = ds.Tables[0].Rows;
                    foreach (DataRow item in drc)
                    {
                        // RegId = "" + item["RegID"];

                    }
                    //msg = "Customer Checkout  From Table" + rpCustomerCheckout.TableId;

                    // GCM STart
                    string RegId = "APA91bHuM_dbxRqmWdV_mnlEg5KmjyVSki7LgnxVkIzF8FC7h6RHcD-0ujawEpzT-Ywugm5h7S-VZHxqVogmWpmJdkM5N6ifTfmPjVILmzEBaMbcqii0QOErl55T-8joDHIubpxxc8b-L_PF8uew2D9oMHydpZJl0Q";
                    string msg = "hello";

                    AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification();
                    //apnGCM.SendNotification(RegId, msg);
                    string deviceId = RegId;// "DEVICE_REGISTRATION_ID";
                    string message = "some test message";
                    string tickerText = "example test GCM";
                    string contentTitle = "content title GCM";
                    string ApiKey = "AIzaSyBjNFw_1Y6W59gTvVaGIrb50NAKwN-LKwQ";
                    string postData =
                    "{ \"registration_ids\": [ \"" + deviceId + "\" ], " +
                      "\"data\": {\"tickerText\":\"" + tickerText + "\", " +
                                 "\"contentTitle\":\"" + contentTitle + "\", " +
                                 "\"message\": \"" + message + "\"}}";

                    string response = apnGCM.SendGCMNotification(ApiKey, postData);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(LogLevelL4N.ERROR, " Unable To Send Notification: | Exception : " + ex.Message);
            }
        }