private async Task RegisterForPushNotification(string deviceToken) { try { var registration = new PushRegistration() { Handle = deviceToken, RegistrationId = RetrieveCurrentRegistrationId?.Invoke(), Platform = PushPlatform.WNS }; var botClientMobileAppClient = new BotClientMobileAppClient(endpointRouteDetails); var hubRegistrationResult = await botClientMobileAppClient.RegisterPushAsync(registration); if (hubRegistrationResult != null) { RegistrationSuccessful?.Invoke(hubRegistrationResult.RegistrationId); } else { RegistrationFailure?.Invoke(new Exception("Registration Failure")); } } catch (Exception ex) { RegistrationFailure?.Invoke(ex); Debug.WriteLine(ex.Message); } }
/// <summary> /// /// </summary> public GcmService() : base(PushHandlerBroadcastReceiver.GoogleApiConsoleAppProjectNumber) { if (string.IsNullOrWhiteSpace(Settings.Instance.PushNotificationSettings?.EndpointRouteDetails?.BaseServiceUrl)) { #if DEBUG throw new Exception("You need to set the BaseServiceUrl, in Settings.Instance.EndpointRouteDetails, before working with Push Notifications"); #endif } else { this.botClientMobileApp = new BotClientMobileAppClient(Settings.Instance.PushNotificationSettings.EndpointRouteDetails); } }