mirror of
https://github.com/bitwarden/mobile
synced 2026-01-02 08:33:17 +00:00
Setup push notifications for android and ios
This commit is contained in:
@@ -21,6 +21,7 @@ using System.Diagnostics;
|
||||
using Xamarin.Forms;
|
||||
using Bit.App;
|
||||
using Bit.iOS.Core.Services;
|
||||
using PushNotification.Plugin;
|
||||
|
||||
namespace Bit.iOS
|
||||
{
|
||||
@@ -128,6 +129,43 @@ namespace Bit.iOS
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
|
||||
{
|
||||
if(CrossPushNotification.Current is IPushNotificationHandler)
|
||||
{
|
||||
((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
|
||||
{
|
||||
if(CrossPushNotification.Current is IPushNotificationHandler)
|
||||
{
|
||||
((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
|
||||
{
|
||||
application.RegisterForRemoteNotifications();
|
||||
}
|
||||
|
||||
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
|
||||
{
|
||||
if(CrossPushNotification.Current is IPushNotificationHandler)
|
||||
{
|
||||
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
|
||||
{
|
||||
if(CrossPushNotification.Current is IPushNotificationHandler)
|
||||
{
|
||||
((IPushNotificationHandler)CrossPushNotification.Current).OnMessageReceived(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendLockMessage()
|
||||
{
|
||||
MessagingCenter.Send(Xamarin.Forms.Application.Current, "Lock", false);
|
||||
@@ -148,6 +186,7 @@ namespace Bit.iOS
|
||||
.RegisterType<ISiteService, SiteService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ISyncService, SyncService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IClipboardService, ClipboardService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IPushNotificationListener, PushNotificationListener>(new ContainerControlledLifetimeManager())
|
||||
// Repositories
|
||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
||||
@@ -160,6 +199,9 @@ namespace Bit.iOS
|
||||
.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
||||
.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
|
||||
|
||||
CrossPushNotification.Initialize(container.Resolve<IPushNotificationListener>());
|
||||
container.RegisterInstance(CrossPushNotification.Current, new ContainerControlledLifetimeManager());
|
||||
|
||||
Resolver.SetResolver(new UnityResolver(container));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,5 +75,9 @@
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -168,6 +168,10 @@
|
||||
<HintPath>..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Connectivity, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.1.2\lib\Xamarin.iOS10\Plugin.Connectivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -192,6 +196,14 @@
|
||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PushNotification.Plugin, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugin.PushNotification.1.2.2\lib\Xamarin.iOS10\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.2\lib\Xamarin.iOS10\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\Xamarin.iOS10\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
<package id="Acr.UserDialogs" version="5.0.1" targetFramework="xamarinios10" />
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
|
||||
<package id="modernhttpclient" version="2.4.2" targetFramework="xamarinios10" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="xamarinios10" />
|
||||
<package id="Plugin.Fingerprint" version="1.1.1-beta" targetFramework="xamarinios10" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="xamarinios10" />
|
||||
<package id="sqlite-net-pcl" version="1.1.1" targetFramework="xamarinios10" />
|
||||
<package id="SQLitePCL.raw" version="0.8.6" targetFramework="xamarinios10" />
|
||||
<package id="Unity" version="3.5.1405-prerelease" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugin.Connectivity" version="2.1.2" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugin.PushNotification" version="1.2.2" targetFramework="xamarinios10" developmentDependency="true" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="xamarinios10" />
|
||||
<package id="Xamarin.Forms" version="2.2.0.31" targetFramework="xamarinios10" />
|
||||
<package id="XLabs.IoC" version="2.0.5782" targetFramework="xamarinios10" />
|
||||
|
||||
Reference in New Issue
Block a user