public Response <NativeNotification> ExtractAndroidNotification(IPushNotification pushNotification) { var body = new StringBuilder(); body.Append("{ "); body.Append("\"notification\" : { "); body.Append("\"title\" : \"").Append(pushNotification.Title).Append("\", "); body.Append("\"body\" : \"").Append(pushNotification.Body).Append("\""); body.Append(" }, "); body.Append("\"data\" : { "); body.Append("\"Template_Name\" : ").Append($"\"{pushNotification.Name}\", "); body.Append("\"Title\" : ").Append($"\"{pushNotification.Title}\", "); body.Append("\"Body\" : ").Append($"\"{pushNotification.Body}\""); foreach (var dataProperty in pushNotification.DataProperties) { body .Append(", \"") .Append(dataProperty.Key).Append("\" : \"").Append(dataProperty.Value).Append("\""); } body.Append(" } }"); var nativeNotification = new NativeNotification(new FcmNotification(body.ToString())); return(Response.Success(nativeNotification)); }
public Response <NativeNotification> ExtractUwpNotification(IPushNotification pushNotification) { var launchProperties = new StringBuilder(); if (pushNotification.DataProperties.Count > 0) { launchProperties.Append("{ "); launchProperties .Append("'Title' : '").Append(pushNotification.Title).Append("', ") .Append("'Body' : '").Append(pushNotification.Body).Append("', ") .Append("'Template_Name' : '").Append(pushNotification.Name).Append("'"); foreach (var dataProperty in pushNotification.DataProperties) { launchProperties .Append(", '") .Append(dataProperty.Key).Append("' : '").Append(dataProperty.Value).Append("'"); } launchProperties.Append(" }"); } var body = new StringBuilder(); body.Append($"<toast launch=\"{launchProperties}\"><visual><binding template=\"ToastText01\">") .Append("<text id=\"1\">").Append(pushNotification.Title).Append("</text>") .Append("<text id=\"2\">").Append(pushNotification.Body).Append("</text>") .Append("</binding></visual></toast>"); var nativeNotification = new NativeNotification(new WindowsNotification(body.ToString())); return(Response.Success(nativeNotification)); }