Esempio n. 1
0
 public async Task <IActionResult> SendPushByTopic(FirebasePayload payload)
 {
     try
     {
         KEFirebaseAdmin app = new KEFirebaseAdmin(payload.AppName);
         String          response;
         try
         {
             response = await app.sendNotificationByTopic(
                 NotificationTypeMode : payload.NotificationTypeMode,
                 topic : payload.Topic,
                 data : payload.Data,
                 notification : payload.Notification,
                 androidIcon : payload.AndroidIcon,
                 androidColor : payload.AndroidColor,
                 apnsBadge : payload.APNSBadge);
         }
         catch (Exception e)
         {
             return(await ResponseData(false, e.Message, ApiResponseMessage.ErrorMessage));
         };
         return(await ResponseData(true, response, ApiResponseMessage.SuccessMessage));
     }
     catch (Exception e)
     {
         string msg = e.Message;
         return(await ResponseData(false, msg, ApiResponseMessage.ErrorMessage));
     }
 }
Esempio n. 2
0
        private FirebasePayload GetFirebasePayload()
        {
            var    data     = new FirebasePayload();
            string filePath = System.IO.Path.Combine(_env.ContentRootPath, "Resources/firebasepayload.json");

            using (StreamReader reader = File.OpenText(filePath))
            {
                string content = reader.ReadToEnd();
                data = JsonConvert.DeserializeObject <FirebasePayload>(content);
            }
            return(data);
        }
Esempio n. 3
0
        public async Task <IActionResult> SendPushByTokens(FirebasePayload payload)
        {
            try
            {
                KEFirebaseAdmin app      = new KEFirebaseAdmin(payload.AppName);
                String          response = await app.sendNotificationByTokens(
                    NotificationTypeMode : payload.NotificationTypeMode,
                    topic : payload.Topic,
                    Tokens : payload.Tokens,
                    data : payload.Data,
                    notification : payload.Notification,
                    androidIcon : payload.AndroidIcon,
                    androidColor : payload.AndroidColor,
                    apnsBadge : payload.APNSBadge
                    );

                return(new ObjectResult(response));
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return(new ObjectResult(msg));
            }
        }