1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-15 07:43:37 +00:00

[SG-702] Tapping Push Notification does not open the account the request is for (#2112)

* [SG-702] Tap notification now switches accounts if it is a passwordless notification.

* [SG-702] Fix compilation errors

* [SG-702] Fixed iOS notification tap fix

* [SG-702] Notification data model

* [SG-702] Change method signature with object containing properties. PR fixes.
This commit is contained in:
André Bispo
2022-10-07 12:06:57 +01:00
committed by GitHub
parent 1e5eab0574
commit abada481b7
11 changed files with 128 additions and 12 deletions

View File

@@ -4,8 +4,13 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Bit.App.Abstractions;
using Bit.App.Models;
using Bit.App.Services;
using Bit.Core;
using Bit.Core.Services;
using Foundation;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UIKit;
using UserNotifications;
@@ -69,9 +74,9 @@ namespace Bit.iOS.Services
return Task.FromResult(0);
}
public void SendLocalNotification(string title, string message, string notificationId)
public void SendLocalNotification(string title, string message, BaseNotificationData data)
{
if (string.IsNullOrEmpty(notificationId))
if (string.IsNullOrEmpty(data.Id))
{
throw new ArgumentNullException("notificationId cannot be null or empty.");
}
@@ -82,7 +87,12 @@ namespace Bit.iOS.Services
Body = message
};
var request = UNNotificationRequest.FromIdentifier(notificationId, content, null);
if (data != null)
{
content.UserInfo = NSDictionary.FromObjectAndKey(NSData.FromString(JsonConvert.SerializeObject(data), NSStringEncoding.UTF8), new NSString(Constants.NotificationData));
}
var request = UNNotificationRequest.FromIdentifier(data.Id, content, null);
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
{
if (err != null)