private (string title, string body) GetTitleAndBodyPlaceHolder(PushNotificationMessageType type) { switch (type) { case PushNotificationMessageType.StartDetected: return(_notificationFrom, _startDetected); case PushNotificationMessageType.FlightEnded: return(_notificationFrom, _flightEnded); case PushNotificationMessageType.BurstDetected: return(_notificationFrom, _burstDetected); default: return(_notificationFrom, "not supported"); } }
public async Task SendMessage(PushNotificationMessageType messageType, Station station, string topic, DateTime date) { var client = new FCMClient(_ApiKey); var context = GetTitleAndBodyPlaceHolder(messageType); var payload = GetPayload(date, station, context.title, context.body); //var topic = stationKey;// "news"; var message = new Message() { To = $"/topics/{topic}_iOS", Data = payload, Notification = new IOSNotificationExtented() { Body = context.body, Title = context.title, MutableContent = "true" //Icon = "myIcon" } }; var result = await client.SendMessageAsync(message); message = new Message() { To = $"/topics/{topic}_Android", Data = payload //Notification = new IOSNotificationExtented() //{ // Body = context.body, // Title = context.title, // MutableContent = "true" // //Icon = "myIcon" //} }; result = await client.SendMessageAsync(message); }