예제 #1
0
        public async Task <FCMSendResponse> SendNotificationAsync(NotificationPostData postData)
        {
            FCMSendResponse sendResponse;

            try
            {
                string content = JsonConvert.SerializeObject(new
                {
                    registration_ids = postData.FcmTokens.ToArray(),
                    priority         = "high",
                    data             = postData.MessageData,
                    notification     = new
                    {
                        body              = postData.MessageData.Message,
                        title             = postData.MessageData.Title,
                        icon              = postData.MessageData.Image,
                        click_action      = postData.MessageData.Link,
                        sound             = "default",
                        content_available = true
                    }
                });
                var body = new StringContent(content, Encoding.UTF8, "application/json");
                sendResponse = await ExecuteFcmPostAsync(body).ConfigureAwait(false);
            }
            catch (Exception)
            {
                sendResponse = new FCMSendResponse()
                {
                    Success = 0
                };
            }

            return(sendResponse);
        }
예제 #2
0
 public FCMSendResponse SendNotification(NotificationPostData postData)
 {
     throw new NotImplementedException();
 }