mirror of
https://github.com/bitwarden/mobile
synced 2026-01-06 02:23:57 +00:00
local push notification implementation from lib
This commit is contained in:
9
src/App/Abstractions/Services/IPushNotification.cs
Normal file
9
src/App/Abstractions/Services/IPushNotification.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Bit.App.Abstractions
|
||||
{
|
||||
public interface IPushNotification
|
||||
{
|
||||
string Token { get; }
|
||||
void Register();
|
||||
void Unregister();
|
||||
}
|
||||
}
|
||||
13
src/App/Abstractions/Services/IPushNotificationListener.cs
Normal file
13
src/App/Abstractions/Services/IPushNotificationListener.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Bit.App.Abstractions
|
||||
{
|
||||
public interface IPushNotificationListener
|
||||
{
|
||||
void OnMessage(JObject values, string device);
|
||||
void OnRegistered(string token, string device);
|
||||
void OnUnregistered(string device);
|
||||
void OnError(string message, string device);
|
||||
bool ShouldShowNotification();
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,8 @@
|
||||
<Compile Include="Abstractions\Repositories\ISettingsRepository.cs" />
|
||||
<Compile Include="Abstractions\Services\IAppSettingsService.cs" />
|
||||
<Compile Include="Abstractions\Services\IMemoryService.cs" />
|
||||
<Compile Include="Abstractions\Services\IPushNotificationListener.cs" />
|
||||
<Compile Include="Abstractions\Services\IPushNotification.cs" />
|
||||
<Compile Include="Abstractions\Services\ISettingsService.cs" />
|
||||
<Compile Include="Abstractions\Services\ITokenService.cs" />
|
||||
<Compile Include="Abstractions\Services\IHttpService.cs" />
|
||||
@@ -87,6 +89,7 @@
|
||||
<Compile Include="Controls\PinControl.cs" />
|
||||
<Compile Include="Controls\VaultAttachmentsViewCell.cs" />
|
||||
<Compile Include="Controls\VaultListViewCell.cs" />
|
||||
<Compile Include="Enums\DeviceType.cs" />
|
||||
<Compile Include="Enums\FieldType.cs" />
|
||||
<Compile Include="Enums\TwoFactorProviderType.cs" />
|
||||
<Compile Include="Enums\EncryptionType.cs" />
|
||||
@@ -355,6 +358,7 @@
|
||||
<Compile Include="Utilities\Extentions.cs" />
|
||||
<Compile Include="Utilities\ExtendedObservableCollection.cs" />
|
||||
<Compile Include="Utilities\ApiHttpClient.cs" />
|
||||
<Compile Include="Utilities\PushNotificationKey.cs" />
|
||||
<Compile Include="Utilities\TokenHttpRequestMessage.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -528,14 +532,6 @@
|
||||
<Reference Include="Plugin.Settings.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugins.Settings.3.0.1\lib\netstandard1.0\Plugin.Settings.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PushNotification.Plugin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.PushNotification.1.2.4\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\PushNotification.Plugin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PushNotification.Plugin.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.PushNotification.1.2.4\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\PushNotification.Plugin.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
9
src/App/Enums/DeviceType.cs
Normal file
9
src/App/Enums/DeviceType.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Bit.App.Enums
|
||||
{
|
||||
public enum DeviceType
|
||||
{
|
||||
Android = 0,
|
||||
iOS = 1,
|
||||
UWP = 16
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Bit.App.Abstractions;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Bit.App.Enums;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Models.Api
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Bit.App.Enums;
|
||||
using System;
|
||||
|
||||
namespace Bit.App.Models.Api
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ using XLabs.Ioc;
|
||||
using Acr.UserDialogs;
|
||||
using System.Threading.Tasks;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Bit.App.Utilities;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
|
||||
@@ -6,7 +6,6 @@ using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using Acr.UserDialogs;
|
||||
using System.Threading.Tasks;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Bit.App.Utilities;
|
||||
using Bit.App.Enums;
|
||||
|
||||
@@ -4,10 +4,7 @@ using Bit.App.Resources;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using Bit.App.Controls;
|
||||
using Acr.UserDialogs;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ using Bit.App.Controls;
|
||||
using Acr.UserDialogs;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using Plugin.Fingerprint.Abstractions;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Bit.App.Utilities;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
|
||||
@@ -9,7 +9,6 @@ using Bit.App.Resources;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using Bit.App.Utilities;
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using Plugin.Settings.Abstractions;
|
||||
using Plugin.Connectivity.Abstractions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using PushNotification.Plugin.Abstractions;
|
||||
using System.Diagnostics;
|
||||
using PushNotification.Plugin;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Bit.App.Abstractions;
|
||||
@@ -37,7 +35,7 @@ namespace Bit.App.Services
|
||||
_resolved = true;
|
||||
}
|
||||
|
||||
public void OnMessage(JObject value, DeviceType deviceType)
|
||||
public void OnMessage(JObject value, string deviceType)
|
||||
{
|
||||
Resolve();
|
||||
|
||||
@@ -144,7 +142,7 @@ namespace Bit.App.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async void OnRegistered(string token, DeviceType deviceType)
|
||||
public async void OnRegistered(string token, string deviceType)
|
||||
{
|
||||
Resolve();
|
||||
|
||||
@@ -168,12 +166,12 @@ namespace Bit.App.Services
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUnregistered(DeviceType deviceType)
|
||||
public void OnUnregistered(string deviceType)
|
||||
{
|
||||
Debug.WriteLine("Push Notification - Device Unnregistered");
|
||||
}
|
||||
|
||||
public void OnError(string message, DeviceType deviceType)
|
||||
public void OnError(string message, string deviceType)
|
||||
{
|
||||
Debug.WriteLine(string.Format("Push notification error - {0}", message));
|
||||
}
|
||||
|
||||
78
src/App/Utilities/PushNotificationKey.cs
Normal file
78
src/App/Utilities/PushNotificationKey.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
namespace Bit.App.Utilities
|
||||
{
|
||||
public static class PushNotificationKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Type
|
||||
/// </summary>
|
||||
public const string Type = "type";
|
||||
/// <summary>
|
||||
/// Error
|
||||
/// </summary>
|
||||
public const string Error = "error";
|
||||
/// <summary>
|
||||
/// Domain Name
|
||||
/// </summary>
|
||||
public const string DomainName = "CrossPushNotification";
|
||||
/// <summary>
|
||||
/// Title
|
||||
/// </summary>
|
||||
public const string Title = "title";
|
||||
/// <summary>
|
||||
/// Text
|
||||
/// </summary>
|
||||
public const string Text = "text";
|
||||
/// <summary>
|
||||
/// Subtitle
|
||||
/// </summary>
|
||||
public const string Subtitle = "subtitle";
|
||||
/// <summary>
|
||||
/// Message
|
||||
/// </summary>
|
||||
public const string Message = "message";
|
||||
/// <summary>
|
||||
/// Silent
|
||||
/// </summary>
|
||||
public const string Silent = "silent";
|
||||
/// <summary>
|
||||
/// Alert
|
||||
/// </summary>
|
||||
public const string Alert = "alert";
|
||||
/// <summary>
|
||||
/// Data
|
||||
/// </summary>
|
||||
public const string Data = "data";
|
||||
/// <summary>
|
||||
/// Token
|
||||
/// </summary>
|
||||
public const string Token = "token";
|
||||
/// <summary>
|
||||
/// App Version
|
||||
/// </summary>
|
||||
public const string AppVersion = "appVersion";
|
||||
/// <summary>
|
||||
/// IntentFromGcmMessage
|
||||
/// </summary>
|
||||
public const string IntentFromGcmMessage = "com.google.android.c2dm.intent.RECEIVE";
|
||||
/// <summary>
|
||||
/// BackOffMilliseconds
|
||||
/// </summary>
|
||||
public const string BackOffMilliseconds = "backoff_ms";
|
||||
/// <summary>
|
||||
/// ErrorServiceNotAvailable
|
||||
/// </summary>
|
||||
public const string ErrorServiceNotAvailable = "SERVICE_NOT_AVAILABLE";
|
||||
/// <summary>
|
||||
/// Tag
|
||||
/// </summary>
|
||||
public const string Tag = "tag";
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
public const string Id = "id";
|
||||
/// <summary>
|
||||
/// RegistrationComplete
|
||||
/// </summary>
|
||||
public const string RegistrationComplete = "registrationComplete";
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
<package id="SQLitePCLRaw.core" version="1.1.8" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Validation" version="2.3.7" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xam.Plugin.Connectivity" version="3.0.2" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xam.Plugin.PushNotification" version="1.2.4" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
|
||||
<package id="Xam.Plugins.Settings" version="3.0.1" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xamarin.FFImageLoading" version="2.2.9" targetFramework="portable45-net45+win8+wpa81" />
|
||||
<package id="Xamarin.FFImageLoading.Forms" version="2.2.9" targetFramework="portable45-net45+win8+wpa81" />
|
||||
|
||||
Reference in New Issue
Block a user