private async Task DeleteInstallationAsync_CreateAndDeleteInstallation_InstallationIsDeleted() { LoadMockData(); await DeleteAllRegistrationsAndInstallations(); var installationId = Guid.NewGuid().ToString(); var installation = new Installation { InstallationId = installationId, Platform = NotificationPlatform.Apns, PushChannel = _configuration["AppleDeviceToken"] }; await _hubClient.CreateOrUpdateInstallationAsync(installation); await Sleep(TimeSpan.FromSeconds(1)); var createdInstallation = await _hubClient.GetInstallationAsync(installationId); await _hubClient.DeleteInstallationAsync(createdInstallation.InstallationId); await Sleep(TimeSpan.FromSeconds(1)); await Assert.ThrowsAsync <MessagingEntityNotFoundException>(async() => await _hubClient.GetInstallationAsync(createdInstallation.InstallationId)); RecordTestResults(); }
public async Task <HttpResponseMessage> DeleteInstallation(string installationId) { try { await _hub.DeleteInstallationAsync(installationId); } catch { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
private static async Task CreateAndDeleteInstallationAsync(NotificationHubClient nhClient) { // Register some fake devices //var fcmDeviceId = Guid.NewGuid().ToString(); var apnsDeviceId = Guid.NewGuid().ToString(); Console.WriteLine($"The APNS device ID is {apnsDeviceId}"); //var fcmInstallation = new Installation var apnsInstallation = new Installation { //InstallationId = fcmDeviceId, InstallationId = apnsDeviceId, Platform = NotificationPlatform.Fcm, //PushChannel = fcmDeviceId, PushChannel = apnsDeviceId, PushChannelExpired = false, //Tags = new[] { "fcm" } Tags = new[] { "apns" } }; //await nhClient.CreateOrUpdateInstallationAsync(fcmInstallation); await nhClient.CreateOrUpdateInstallationAsync(apnsInstallation); while (true) { try { //var installationFromServer = await nhClient.GetInstallationAsync(fcmInstallation.InstallationId); var installationFromServer = await nhClient.GetInstallationAsync(apnsInstallation.InstallationId); break; } catch (MessagingEntityNotFoundException) { // Wait for installation to be created await Task.Delay(1000); } } //Console.WriteLine($"Created FCM installation {fcmInstallation.InstallationId}"); Console.WriteLine($"Created APNS installation {apnsInstallation.InstallationId}"); //await nhClient.DeleteInstallationAsync(fcmInstallation.InstallationId); await nhClient.DeleteInstallationAsync(apnsInstallation.InstallationId); while (true) { try { //var installationFromServer = await nhClient.GetInstallationAsync(fcmInstallation.InstallationId); var installationFromServer = await nhClient.GetInstallationAsync(apnsInstallation.InstallationId); await Task.Delay(1000); } catch (MessagingEntityNotFoundException) { //Console.WriteLine($"Deleted FCM installation {fcmInstallation.InstallationId}"); Console.WriteLine($"Deleted APNS installation {apnsInstallation.InstallationId}"); break; } } }
public async Task DeleteDeviceInstallation(string id) { try { await _hubClient.DeleteInstallationAsync(id); } catch (Exception ex) { throw ex; } }
public async Task DeleteRegistrationAsync(string deviceId) { try { await _client.DeleteInstallationAsync(deviceId); } catch (Exception e) { if (e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found")) { throw e; } } }
public async Task DeleteRegistrationAsync(string deviceId) { try { await _client.DeleteInstallationAsync(deviceId); if (InstallationDeviceEntity.IsInstallationDeviceId(deviceId)) { await _installationDeviceRepository.DeleteAsync(new InstallationDeviceEntity(deviceId)); } } catch (Exception e) when(e.InnerException == null || !e.InnerException.Message.Contains("(404) Not Found")) { throw; } }
private static async Task CreateAndDeleteInstallationAsync(NotificationHubClient nhClient) { // Register some fake devices var gcmDeviceId = Guid.NewGuid().ToString(); var gcmInstallation = new Installation { InstallationId = gcmDeviceId, Platform = NotificationPlatform.Gcm, PushChannel = gcmDeviceId, PushChannelExpired = false, Tags = new[] { "gcm" } }; await nhClient.CreateOrUpdateInstallationAsync(gcmInstallation); while (true) { try { var installationFromServer = await nhClient.GetInstallationAsync(gcmInstallation.InstallationId); break; } catch (MessagingEntityNotFoundException) { // Wait for installation to be created await Task.Delay(1000); } } Console.WriteLine($"Created GCM installation {gcmInstallation.InstallationId}"); await nhClient.DeleteInstallationAsync(gcmInstallation.InstallationId); while (true) { try { var installationFromServer = await nhClient.GetInstallationAsync(gcmInstallation.InstallationId); await Task.Delay(1000); } catch (MessagingEntityNotFoundException) { Console.WriteLine($"Deleted GCM installation {gcmInstallation.InstallationId}"); break; } } }
public async Task <bool> DeleteInstallationByIdAsync(string installationId, CancellationToken token) { if (string.IsNullOrWhiteSpace(installationId)) { return(false); } try { await _hub.DeleteInstallationAsync(installationId, token); } catch { return(false); } return(true); }
public async Task <bool> DeleteInstallationByIdAsync(string installationId, CancellationToken token) { if (string.IsNullOrWhiteSpace(installationId)) { return(false); } try { await _hub.DeleteInstallationAsync(installationId, token); _logger.LogInformation($"Device Id {installationId} unregistered"); } catch (Exception e) { _logger.LogError(e, "Unexpected error device installation deletion"); return(false); } return(true); }
public async Task DeleteRegistrationAsync(Guid deviceId) { await _client.DeleteInstallationAsync(deviceId.ToString()); }
public async Task DisconnectAsync(string trackingNumber) { await _hub.DeleteInstallationAsync(trackingNumber); }
public async Task RemoveRegistration(string installationId) { await hub.DeleteInstallationAsync(installationId); return; }
public static async Task RemoveDevice(string installationId) { await notitifcationHubClient.DeleteInstallationAsync(installationId); }
public async Task DeleteRegistrationAsync(string deviceId) { await _client.DeleteInstallationAsync(deviceId); }