コード例 #1
0
ファイル: RealmController.cs プロジェクト: DotNetRu/App
        private async Task SendMeetupsNotifications(AuditXmlUpdate auditUpdate)
        {
            foreach (var meetup in auditUpdate.Meetups.Where(meetup => meetup.Sessions.First().StartTime > DateTime.Now))
            {
                var pushContent = new PushContent()
                {
                    Title = $"{meetup.Name} is announced!",
                    Body  = "Open DotNetRu app for details"
                };

                await pushNotificationsManager.SendPushNotifications(pushContent);
            }
        }
コード例 #2
0
        public async Task <IActionResult> Run([FromBody] PushContent pushContent)
        {
            try
            {
                await pushNotificationsManager.SendPushNotifications(pushContent);
            }
            catch (Exception e)
            {
                logger.LogCritical(e, "Error while sending push notifications");
                return(new ObjectResult(e.Message)
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }

            return(new OkResult());
        }