diff --git a/src/App/Services/PushNotificationListener.cs b/src/App/Services/PushNotificationListener.cs index ba075efcf..c59109b81 100644 --- a/src/App/Services/PushNotificationListener.cs +++ b/src/App/Services/PushNotificationListener.cs @@ -7,34 +7,40 @@ using Bit.App.Abstractions; using Bit.App.Models; using Plugin.Settings.Abstractions; using System; +using XLabs.Ioc; namespace Bit.App.Services { public class PushNotificationListener : IPushNotificationListener { private bool _showNotification; - private readonly ISyncService _syncService; - private readonly IDeviceApiRepository _deviceApiRepository; - private readonly IAuthService _authService; - private readonly IAppIdService _appIdService; - private readonly ISettings _settings; + private bool _resolved; + private ISyncService _syncService; + private IDeviceApiRepository _deviceApiRepository; + private IAuthService _authService; + private IAppIdService _appIdService; + private ISettings _settings; - public PushNotificationListener( - ISyncService syncService, - IDeviceApiRepository deviceApiRepository, - IAuthService authService, - IAppIdService appIdService, - ISettings settings) + private void Resolve() { - _syncService = syncService; - _deviceApiRepository = deviceApiRepository; - _authService = authService; - _appIdService = appIdService; - _settings = settings; + if(_resolved) + { + return; + } + + _syncService = Resolver.Resolve(); + _deviceApiRepository = Resolver.Resolve(); + _authService = Resolver.Resolve(); + _appIdService = Resolver.Resolve(); + _settings = Resolver.Resolve(); + + _resolved = true; } public void OnMessage(JObject value, DeviceType deviceType) { + Resolve(); + if(value == null) { return; @@ -140,6 +146,8 @@ namespace Bit.App.Services public async void OnRegistered(string token, DeviceType deviceType) { + Resolve(); + Debug.WriteLine(string.Format("Push Notification - Device Registered - Token : {0}", token)); if(!_authService.IsAuthenticated)