mirror of
https://github.com/bitwarden/android.git
synced 2025-03-29 00:59:19 +03:00
resolve push JIT
This commit is contained in:
parent
0b24cc29c1
commit
5d2138b95e
1 changed files with 24 additions and 16 deletions
|
@ -7,34 +7,40 @@ using Bit.App.Abstractions;
|
||||||
using Bit.App.Models;
|
using Bit.App.Models;
|
||||||
using Plugin.Settings.Abstractions;
|
using Plugin.Settings.Abstractions;
|
||||||
using System;
|
using System;
|
||||||
|
using XLabs.Ioc;
|
||||||
|
|
||||||
namespace Bit.App.Services
|
namespace Bit.App.Services
|
||||||
{
|
{
|
||||||
public class PushNotificationListener : IPushNotificationListener
|
public class PushNotificationListener : IPushNotificationListener
|
||||||
{
|
{
|
||||||
private bool _showNotification;
|
private bool _showNotification;
|
||||||
private readonly ISyncService _syncService;
|
private bool _resolved;
|
||||||
private readonly IDeviceApiRepository _deviceApiRepository;
|
private ISyncService _syncService;
|
||||||
private readonly IAuthService _authService;
|
private IDeviceApiRepository _deviceApiRepository;
|
||||||
private readonly IAppIdService _appIdService;
|
private IAuthService _authService;
|
||||||
private readonly ISettings _settings;
|
private IAppIdService _appIdService;
|
||||||
|
private ISettings _settings;
|
||||||
|
|
||||||
public PushNotificationListener(
|
private void Resolve()
|
||||||
ISyncService syncService,
|
|
||||||
IDeviceApiRepository deviceApiRepository,
|
|
||||||
IAuthService authService,
|
|
||||||
IAppIdService appIdService,
|
|
||||||
ISettings settings)
|
|
||||||
{
|
{
|
||||||
_syncService = syncService;
|
if(_resolved)
|
||||||
_deviceApiRepository = deviceApiRepository;
|
{
|
||||||
_authService = authService;
|
return;
|
||||||
_appIdService = appIdService;
|
}
|
||||||
_settings = settings;
|
|
||||||
|
_syncService = Resolver.Resolve<ISyncService>();
|
||||||
|
_deviceApiRepository = Resolver.Resolve<IDeviceApiRepository>();
|
||||||
|
_authService = Resolver.Resolve<IAuthService>();
|
||||||
|
_appIdService = Resolver.Resolve<IAppIdService>();
|
||||||
|
_settings = Resolver.Resolve<ISettings>();
|
||||||
|
|
||||||
|
_resolved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMessage(JObject value, DeviceType deviceType)
|
public void OnMessage(JObject value, DeviceType deviceType)
|
||||||
{
|
{
|
||||||
|
Resolve();
|
||||||
|
|
||||||
if(value == null)
|
if(value == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -140,6 +146,8 @@ namespace Bit.App.Services
|
||||||
|
|
||||||
public async void OnRegistered(string token, DeviceType deviceType)
|
public async void OnRegistered(string token, DeviceType deviceType)
|
||||||
{
|
{
|
||||||
|
Resolve();
|
||||||
|
|
||||||
Debug.WriteLine(string.Format("Push Notification - Device Registered - Token : {0}", token));
|
Debug.WriteLine(string.Format("Push Notification - Device Registered - Token : {0}", token));
|
||||||
|
|
||||||
if(!_authService.IsAuthenticated)
|
if(!_authService.IsAuthenticated)
|
||||||
|
|
Loading…
Add table
Reference in a new issue