mirror of
https://github.com/bitwarden/android.git
synced 2024-12-26 19:08:32 +03:00
[SG-703] Login request is not removed after dismissing push notification (#2134)
* [SG-703] Added category to iOS notifications in order to be able to receive dismiss actions * [SG-703] PR Fix
This commit is contained in:
parent
6c404c8229
commit
c7e9f30a9a
2 changed files with 9 additions and 1 deletions
|
@ -32,6 +32,8 @@
|
||||||
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
|
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
|
||||||
public const string PasswordlessNotificationId = "26072022";
|
public const string PasswordlessNotificationId = "26072022";
|
||||||
public const string AndroidNotificationChannelId = "general_notification_channel";
|
public const string AndroidNotificationChannelId = "general_notification_channel";
|
||||||
|
public const string iOSNotificationCategoryId = "dismissableCategory";
|
||||||
|
public const string iOSNotificationClearActionId = "Clear";
|
||||||
public const string NotificationData = "notificationData";
|
public const string NotificationData = "notificationData";
|
||||||
public const string NotificationDataType = "Type";
|
public const string NotificationDataType = "Type";
|
||||||
public const int SelectFileRequestCode = 42;
|
public const int SelectFileRequestCode = 42;
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using Bit.App.Models;
|
using Bit.App.Models;
|
||||||
|
using Bit.App.Resources;
|
||||||
using Bit.App.Services;
|
using Bit.App.Services;
|
||||||
using Bit.Core;
|
using Bit.Core;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
|
@ -84,7 +85,8 @@ namespace Bit.iOS.Services
|
||||||
var content = new UNMutableNotificationContent()
|
var content = new UNMutableNotificationContent()
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
Body = message
|
Body = message,
|
||||||
|
CategoryIdentifier = Constants.iOSNotificationCategoryId
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
|
@ -92,6 +94,10 @@ namespace Bit.iOS.Services
|
||||||
content.UserInfo = NSDictionary.FromObjectAndKey(NSData.FromString(JsonConvert.SerializeObject(data), NSStringEncoding.UTF8), new NSString(Constants.NotificationData));
|
content.UserInfo = NSDictionary.FromObjectAndKey(NSData.FromString(JsonConvert.SerializeObject(data), NSStringEncoding.UTF8), new NSString(Constants.NotificationData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actions = new UNNotificationAction[] { UNNotificationAction.FromIdentifier(Constants.iOSNotificationClearActionId, AppResources.Clear, UNNotificationActionOptions.Foreground) };
|
||||||
|
var category = UNNotificationCategory.FromIdentifier(Constants.iOSNotificationCategoryId, actions, new string[] { }, UNNotificationCategoryOptions.CustomDismissAction);
|
||||||
|
UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet<UNNotificationCategory>(category));
|
||||||
|
|
||||||
var request = UNNotificationRequest.FromIdentifier(data.Id, content, null);
|
var request = UNNotificationRequest.FromIdentifier(data.Id, content, null);
|
||||||
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
|
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue