Exemple #1
0
        public bool sendFCMNotification(string token, string title, string message)
        {
            bool IsSendToFcm = false;

            try
            {
                #region Send Spectro Data To FCM

                FCMNotification.FCMResponseObject FCM_Response = new FCMNotification.FCMResponseObject();
                FCMNotification notification = new FCMNotification();

                if (!String.IsNullOrEmpty(token))
                {
                    string response = notification.PushNotifyAsync(token, title, message);
                    FCM_Response = Newtonsoft.Json.JsonConvert.DeserializeObject <FCMNotification.FCMResponseObject>(response);
                    if (FCM_Response.success > 0 && FCM_Response.failure == 0)
                    {
                        IsSendToFcm = true;
                    }
                    else
                    {
                        IsSendToFcm = false;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
            }
            return(IsSendToFcm);
        }
Exemple #2
0
    public static bool sendFCMNotification(string token, string title, string message)
    {
        bool IsSendToFcm = false;

        try
        {
            #region Send Spectro Data To FCM

            FCMNotification.FCMResponseObject FCM_Response = new FCMNotification.FCMResponseObject();
            FCMNotification notification = new FCMNotification();

            if (!String.IsNullOrEmpty(token))
            {
                string response = notification.PushNotifyAsync(token, title, message);
                FCM_Response = Newtonsoft.Json.JsonConvert.DeserializeObject <FCMNotification.FCMResponseObject>(response);
                if (FCM_Response.success > 0 && FCM_Response.failure == 0)
                {
                    IsSendToFcm = true;
                }
                else
                {
                    IsSendToFcm = false;
                }
            }

            #endregion
        }
        catch (Exception ex)
        {
            //IsSendToFcm = false;
            //Console.WriteLine(ex.Message);
            //using (System.IO.StreamWriter file = new System.IO.StreamWriter(GetDirectory + "\\ErrorLog.txt", true))
            //{
            //    file.WriteLine("Date >> " + DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss tt") + " >> ERROR >> " + ex.Message.ToString());
            //}
        }
        return(IsSendToFcm);
    }
    public static bool SendPushNotification(string device_token, string body_data, Guid guid, int devicetype)
    {
        bool IsSendToFcm = false;

        try
        {
            FCMNotification fcmpush = new FCMNotification();
            FCMResponse     s       = fcmpush.PushNotifyAsync(device_token, body_data, guid, devicetype);
            if (s.success > 0)
            {
                IsSendToFcm = true;
            }
            else
            {
                IsSendToFcm = false;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return(IsSendToFcm);
    }