mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
* [SG-703] Handle iOS dismiss notification action. Added core logic to remove passwordless notification from local storage. * [SG-702] Added broadcast receiver to catch dismiss notfication events on android. * [SG-703] PR fixes. * [SG-703] Fix constants namespaces. Lazyloading services on broadcast receiver. * [SG-703] Change services to use lazy loading * [SG-703] Change lazy loading to be parameterless.
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using Android.Content;
|
|
using Bit.App.Abstractions;
|
|
using Bit.App.Models;
|
|
using Bit.App.Services;
|
|
using Bit.Core;
|
|
using Bit.Core.Abstractions;
|
|
using Bit.Core.Services;
|
|
using Bit.Core.Utilities;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using CoreConstants = Bit.Core.Constants;
|
|
|
|
namespace Bit.Droid.Receivers
|
|
{
|
|
[BroadcastReceiver(Name = Constants.PACKAGE_NAME + "." + nameof(NotificationDismissReceiver), Exported = false)]
|
|
public class NotificationDismissReceiver : BroadcastReceiver
|
|
{
|
|
private readonly LazyResolve<IPushNotificationListenerService> _pushNotificationListenerService = new LazyResolve<IPushNotificationListenerService>();
|
|
private readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>();
|
|
|
|
public override void OnReceive(Context context, Intent intent)
|
|
{
|
|
try
|
|
{
|
|
if (intent?.GetStringExtra(CoreConstants.NotificationData) is string notificationDataJson)
|
|
{
|
|
var notificationType = JToken.Parse(notificationDataJson).SelectToken(CoreConstants.NotificationDataType);
|
|
if (notificationType.ToString() == PasswordlessNotificationData.TYPE)
|
|
{
|
|
_pushNotificationListenerService.Value.OnNotificationDismissed(JsonConvert.DeserializeObject<PasswordlessNotificationData>(notificationDataJson)).FireAndForget();
|
|
}
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
_logger.Value.Exception(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|