public async Task <HttpResponseMessage> PostPush([FromBody] PushBotsModel push) { try { var pushMessage = new BatchPush { Message = push.Message, Alias = push.Alias, Sound = "", Badge = "+1", Platforms = new[] { Platform.Android, Platform.iOS } }; ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) => { return(true); }; var result = await _pushBotsClient.Push(pushMessage); if (result.IsSuccessStatusCode) { return(Request.CreateResponse(HttpStatusCode.OK, result.ReasonPhrase)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Couldn't find device with alias: " + result.StatusCode)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.GetBaseException().Message)); } }
public void PushNotificationsAsync() { var payload = new JObject(); payload.Add("ntitle", "CareMe"); payload.Add("message", "Co-ordinator has a question for you!!"); payload.Add("inboxStyle", "true"); var pushMessage = new BatchPush() { Message = "Survey Received!!", Badge = "+1", Platforms = new[] { Platform.Android, Platform.iOS }, Payload = payload }; var result = PushBots_Client.Push(pushMessage); }
/// <summary> /// Push a notification to Devices under certain conditions /// </summary> /// <see cref="https://pushbots.com/developer/api/1#batch_push"/> /// <param name="message"></param> /// <returns></returns> public async Task <HttpResponseMessage> Push(BatchPush message) { var client = _clientFactory.GetClient(AppId, Secret); return(await client.PostAsJsonAsync(_settings.BatchPushApiPath, message)); }