public async Task AddUserRegistrationOrganizationAsync(IEnumerable <string> deviceIds, string organizationId) { if (!deviceIds.Any()) { return; } var tokenStateResponse = await HandleTokenStateAsync(); if (!tokenStateResponse) { return; } var requestModel = new PushUpdateRequestModel(deviceIds, organizationId); var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Put, RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/add-organization")) }; try { await PushClient.SendAsync(message); } catch (Exception e) { _logger.LogError(12337, e, "Unable to add user org push registration."); } }
public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId, string identifier, DeviceType type) { var tokenStateResponse = await HandleTokenStateAsync(); if (!tokenStateResponse) { return; } var requestModel = new PushRegistrationRequestModel { DeviceId = deviceId, Identifier = identifier, PushToken = pushToken, Type = type, UserId = userId }; var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Post, RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/register")) }; try { await PushClient.SendAsync(message); } catch (Exception e) { _logger.LogError(12335, e, "Unable to create push registration."); } }
private static async void SendPush(ApiServices service, IPushMessage message) { try { PushClient cliente = new PushClient(service); await cliente.SendAsync(message); } catch (System.Exception ex) { } }
public async Task DeleteRegistrationAsync(string deviceId) { var tokenStateResponse = await HandleTokenStateAsync(); if (!tokenStateResponse) { return; } var message = new TokenHttpRequestMessage(AccessToken) { Method = HttpMethod.Delete, RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/", deviceId)) }; try { await PushClient.SendAsync(message); } catch (Exception e) { _logger.LogError(12336, e, "Unable to delete push registration."); } }
private async Task SendAsync(PushSendRequestModel requestModel) { var tokenStateResponse = await HandleTokenStateAsync(); if (!tokenStateResponse) { return; } var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Post, RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/send")) }; try { await PushClient.SendAsync(message); } catch (Exception e) { _logger.LogError(12334, e, "Unable to send push notification."); } }