1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-11 22:03:27 +00:00

push notification services

This commit is contained in:
Kyle Spearrin
2019-05-28 12:01:55 -04:00
parent faccb61a6b
commit 3f11fdaa82
24 changed files with 1982 additions and 1256 deletions

View File

@@ -0,0 +1,36 @@
using System.Threading.Tasks;
using Bit.App.Abstractions;
using Foundation;
using UIKit;
namespace Bit.iOS.Services
{
public class iOSPushNotificationService : IPushNotificationService
{
private const string TokenSetting = "token";
public Task<string> GetTokenAsync()
{
return Task.FromResult(NSUserDefaults.StandardUserDefaults.StringForKey(TokenSetting));
}
public Task RegisterAsync()
{
var userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge |
UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(userNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
return Task.FromResult(0);
}
public Task UnregisterAsync()
{
UIApplication.SharedApplication.UnregisterForRemoteNotifications();
// TODO: unregister call
// _pushNotificationListener.OnUnregistered(Device.iOS);
NSUserDefaults.StandardUserDefaults.SetString(string.Empty, TokenSetting);
NSUserDefaults.StandardUserDefaults.Synchronize();
return Task.FromResult(0);
}
}
}