mirror of
https://github.com/bitwarden/mobile
synced 2025-12-27 21:53:57 +00:00
Cleared Console.WriteLine for iOS push notifications issue (#1739)
This commit is contained in:
committed by
GitHub
parent
c0c893fd59
commit
d0ffb108b1
@@ -251,36 +251,30 @@ namespace Bit.iOS
|
||||
return base.ContinueUserActivity(application, userActivity, completionHandler);
|
||||
}
|
||||
|
||||
const string TAG = "##PUSH NOTIFICATIONS";
|
||||
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
|
||||
{
|
||||
Console.WriteLine($"{TAG} FailedToRegisterForRemoteNotifications");
|
||||
_pushHandler?.OnErrorReceived(error);
|
||||
}
|
||||
|
||||
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
|
||||
{
|
||||
Console.WriteLine($"{TAG} RegisteredForRemoteNotifications");
|
||||
_pushHandler?.OnRegisteredSuccess(deviceToken);
|
||||
}
|
||||
|
||||
public override void DidRegisterUserNotificationSettings(UIApplication application,
|
||||
UIUserNotificationSettings notificationSettings)
|
||||
{
|
||||
Console.WriteLine($"{TAG} DidRegisterUserNotificationSettings");
|
||||
application.RegisterForRemoteNotifications();
|
||||
}
|
||||
|
||||
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo,
|
||||
Action<UIBackgroundFetchResult> completionHandler)
|
||||
{
|
||||
Console.WriteLine($"{TAG} DidReceiveRemoteNotification");
|
||||
_pushHandler?.OnMessageReceived(userInfo);
|
||||
}
|
||||
|
||||
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
|
||||
{
|
||||
Console.WriteLine($"{TAG} ReceivedRemoteNotification");
|
||||
_pushHandler?.OnMessageReceived(userInfo);
|
||||
}
|
||||
|
||||
@@ -321,8 +315,6 @@ namespace Bit.iOS
|
||||
|
||||
private void RegisterPush()
|
||||
{
|
||||
Console.WriteLine($"{TAG} RegisterPush");
|
||||
|
||||
var notificationListenerService = new PushNotificationListenerService();
|
||||
ServiceContainer.Register<IPushNotificationListenerService>(
|
||||
"pushNotificationListenerService", notificationListenerService);
|
||||
|
||||
@@ -12,8 +12,6 @@ namespace Bit.iOS.Services
|
||||
public class iOSPushNotificationHandler : NSObject, IUNUserNotificationCenterDelegate
|
||||
{
|
||||
private const string TokenSetting = "token";
|
||||
//private const string DomainName = "iOSPushNotificationService";
|
||||
|
||||
const string TAG = "##PUSH NOTIFICATIONS";
|
||||
|
||||
private readonly IPushNotificationListenerService _pushNotificationListenerService;
|
||||
@@ -28,7 +26,7 @@ namespace Bit.iOS.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"{TAG} - OnMessageReceived.");
|
||||
Debug.WriteLine($"{TAG} - OnMessageReceived.");
|
||||
|
||||
var json = DictionaryToJson(userInfo);
|
||||
var values = JObject.Parse(json);
|
||||
@@ -53,19 +51,19 @@ namespace Bit.iOS.Services
|
||||
|
||||
public void OnErrorReceived(NSError error)
|
||||
{
|
||||
Console.WriteLine($"{TAG} - Registration Failed.");
|
||||
Debug.WriteLine($"{TAG} - Registration Failed.");
|
||||
_pushNotificationListenerService.OnError(error.LocalizedDescription, Device.iOS);
|
||||
}
|
||||
|
||||
public void OnRegisteredSuccess(NSData token)
|
||||
{
|
||||
Console.WriteLine($"{TAG} - Successfully Registered.");
|
||||
Debug.WriteLine($"{TAG} - Successfully Registered.");
|
||||
|
||||
var hexDeviceToken = BitConverter.ToString(token.ToArray())
|
||||
.Replace("-", string.Empty)
|
||||
.ToLowerInvariant();
|
||||
|
||||
Console.WriteLine($"{TAG} - Token: {hexDeviceToken}");
|
||||
Debug.WriteLine($"{TAG} - Token: {hexDeviceToken}");
|
||||
|
||||
UNUserNotificationCenter.Current.Delegate = this;
|
||||
|
||||
@@ -84,7 +82,7 @@ namespace Bit.iOS.Services
|
||||
[Export("userNotificationCenter:willPresentNotification:withCompletionHandler:")]
|
||||
public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
|
||||
{
|
||||
Console.WriteLine($"{TAG} WillPresentNotification {notification?.Request?.Content?.UserInfo}");
|
||||
Debug.WriteLine($"{TAG} WillPresentNotification {notification?.Request?.Content?.UserInfo}");
|
||||
|
||||
OnMessageReceived(notification?.Request?.Content?.UserInfo);
|
||||
completionHandler(UNNotificationPresentationOptions.Alert);
|
||||
@@ -93,7 +91,7 @@ namespace Bit.iOS.Services
|
||||
[Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")]
|
||||
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
|
||||
{
|
||||
Console.WriteLine($"{TAG} DidReceiveNotificationResponse {response?.Notification?.Request?.Content?.UserInfo}");
|
||||
Debug.WriteLine($"{TAG} DidReceiveNotificationResponse {response?.Notification?.Request?.Content?.UserInfo}");
|
||||
|
||||
if (response.IsDefaultAction)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Abstractions;
|
||||
using Foundation;
|
||||
@@ -22,7 +21,7 @@ namespace Bit.iOS.Services
|
||||
|
||||
public async Task RegisterAsync()
|
||||
{
|
||||
Console.WriteLine($"{TAG} RegisterAsync");
|
||||
Debug.WriteLine($"{TAG} RegisterAsync");
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
@@ -31,11 +30,11 @@ namespace Bit.iOS.Services
|
||||
{
|
||||
if (error != null)
|
||||
{
|
||||
Console.WriteLine($"{TAG} {error}");
|
||||
Debug.WriteLine($"{TAG} {error}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"{TAG} {granted}");
|
||||
Debug.WriteLine($"{TAG} {granted}");
|
||||
}
|
||||
|
||||
tcs.SetResult(granted);
|
||||
@@ -43,14 +42,14 @@ namespace Bit.iOS.Services
|
||||
|
||||
if (await tcs.Task)
|
||||
{
|
||||
Console.WriteLine($"{TAG} RegisterForRemoteNotifications");
|
||||
Debug.WriteLine($"{TAG} RegisterForRemoteNotifications");
|
||||
UIApplication.SharedApplication.RegisterForRemoteNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
public Task UnregisterAsync()
|
||||
{
|
||||
Console.WriteLine($"{TAG} UnregisterAsync");
|
||||
Debug.WriteLine($"{TAG} UnregisterAsync");
|
||||
|
||||
UIApplication.SharedApplication.UnregisterForRemoteNotifications();
|
||||
// TODO: unregister call
|
||||
|
||||
Reference in New Issue
Block a user