Skip to content

Commit ac9fdf5

Browse files
Merge branch 'master' of github.com:notifo-io/sdk-xamarin into worker-package
# Conflicts: # sdk/Notifo.SDK.FirebasePlugin/Notifo.SDK.FirebasePlugin.csproj # sdk/Notifo.SDK.FirebasePlugin/PluginEventsProvider.cs # sdk/Notifo.SDK/NotifoMobilePush/NotifoMobilePushImplementation.cs
2 parents f57af43 + 6afba7f commit ac9fdf5

34 files changed

+465
-549
lines changed

sample/Sample.iOS.Shared/Sample.iOS.Shared.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</ProjectReference>
5151
</ItemGroup>
5252
<ItemGroup>
53-
<PackageReference Include="Notifo.SDK" Version="1.5.1" />
53+
<PackageReference Include="Notifo.SDK" Version="1.6.4" />
5454
</ItemGroup>
5555
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
5656
</Project>

sample/Sample/ViewModels/EventsPageViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private void RefreshEventsAsync()
6767
{
6868
try
6969
{
70-
var notifications = await notifoService.Notifications.GetMyNotificationsAsync();
70+
var notifications = await notifoService.Client.Notifications.GetMyNotificationsAsync();
7171

7272
Notifications.ReplaceRange(notifications.Items);
7373
}

sample/SampleNotificationServiceExtension/SampleNotificationServiceExtension.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
9191
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
9292
</Reference>
93-
<Reference Include="Notifo.SDK, Version=1.5.1.0, Culture=neutral, processorArchitecture=MSIL">
94-
<HintPath>..\..\packages\Notifo.SDK.1.5.1\lib\netstandard2.1\Notifo.SDK.dll</HintPath>
93+
<Reference Include="Notifo.SDK, Version=1.6.4.0, Culture=neutral, processorArchitecture=MSIL">
94+
<HintPath>..\..\packages\Notifo.SDK.1.6.4\lib\netstandard2.1\Notifo.SDK.dll</HintPath>
9595
</Reference>
9696
<Reference Include="System" />
9797
<Reference Include="System.Xml" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="xamarinios10" />
4-
<package id="Notifo.SDK" version="1.5.1" targetFramework="xamarinios10" />
4+
<package id="Notifo.SDK" version="1.6.4" targetFramework="xamarinios10" />
55
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="xamarinios10" />
66
</packages>

sdk/Notifo.SDK.FirebasePlugin/Notifo.SDK.FirebasePlugin.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
</ItemGroup>
5555

5656
<ItemGroup>
57-
<PackageReference Include="Notifo.SDK" Version="1.5.1" />
58-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
57+
<PackageReference Include="Notifo.SDK" Version="1.6.4" />
58+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
5959
</ItemGroup>
6060

6161
<ItemGroup>
Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,61 @@
1-
// ==========================================================================
2-
// Notifo.io
3-
// ==========================================================================
4-
// Copyright (c) Sebastian Stehle
5-
// All rights reserved. Licensed under the MIT license.
6-
// ==========================================================================
7-
8-
using System;
9-
using System.Threading.Tasks;
10-
using Foundation;
11-
using Notifo.SDK.Resources;
12-
using Notifo.SDK;
13-
using Plugin.FirebasePushNotification;
14-
using Serilog;
1+
// ==========================================================================
2+
// Notifo.io
3+
// ==========================================================================
4+
// Copyright (c) Sebastian Stehle
5+
// All rights reserved. Licensed under the MIT license.
6+
// ==========================================================================
7+
8+
using System;
9+
using System.Threading.Tasks;
10+
using Foundation;
11+
using Notifo.SDK.Resources;
12+
using Notifo.SDK;
13+
using Plugin.FirebasePushNotification;
1514
using UserNotifications;
16-
17-
namespace Notifo.SDK.FirebasePlugin
15+
16+
namespace Notifo.SDK.FirebasePlugin
1817
{
1918
/// <summary>
2019
/// Plugin initialization.
21-
/// </summary>
22-
public class NotifoFirebasePlugin
23-
{
20+
/// </summary>
21+
public class NotifoFirebasePlugin
22+
{
2423
/// <summary>
2524
/// Initializes the firebase plugin.
2625
/// </summary>
2726
/// <param name="options">Application launch options.</param>
2827
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
2928
/// <param name="notificationHandler">The <see cref="INotificationHandler"/> implementation.</param>
30-
/// <param name="autoRegistration">Automatically register for push notifications.</param>
31-
public static void Initialize(NSDictionary options, INotifoStartup notifoStartup, INotificationHandler notificationHandler = null, bool autoRegistration = true)
32-
{
33-
FirebasePushNotificationManager.Initialize(options, autoRegistration);
34-
35-
NotifoIO.Current.SetNotificationHandler(notificationHandler);
36-
notifoStartup.ConfigureService(NotifoIO.Current);
37-
}
38-
29+
/// <param name="autoRegistration">Automatically register for push notifications.</param>
30+
public static void Initialize(NSDictionary options, INotifoStartup notifoStartup, INotificationHandler notificationHandler = null, bool autoRegistration = true)
31+
{
32+
FirebasePushNotificationManager.Initialize(options, autoRegistration);
33+
34+
NotifoIO.Current.SetNotificationHandler(notificationHandler);
35+
notifoStartup.ConfigureService(NotifoIO.Current);
36+
}
37+
3938
/// <summary>
4039
/// Invoked when the application received a remote notification.
4140
/// </summary>
4241
/// <param name="data">The notification data dictionary.</param>
43-
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
44-
public static async Task DidReceiveMessageAsync(NSDictionary data)
45-
{
46-
Log.Debug(Strings.ReceivedNotification, data);
47-
48-
if (ContainsPullRefreshRequest(data))
49-
{
50-
await NotifoIO.DidReceivePullRefreshRequestAsync();
51-
}
52-
53-
FirebasePushNotificationManager.DidReceiveMessage(data);
54-
}
55-
42+
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
43+
public static async Task DidReceiveMessageAsync(NSDictionary data)
44+
{
45+
NotifoIO.Current.RaiseDebug(Strings.ReceivedNotification, null, data);
46+
47+
if (ContainsPullRefreshRequest(data))
48+
{
49+
await NotifoIO.DidReceivePullRefreshRequestAsync();
50+
}
51+
52+
FirebasePushNotificationManager.DidReceiveMessage(data);
53+
}
54+
5655
/// <summary>
5756
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> succeeded.
5857
/// </summary>
59-
/// <param name="deviceToken">The device token.</param>
58+
/// <param name="deviceToken">The device token.</param>
6059
public static void DidRegisterRemoteNotifications(NSData deviceToken)
6160
{
6261
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
@@ -65,7 +64,7 @@ public static void DidRegisterRemoteNotifications(NSData deviceToken)
6564
/// <summary>
6665
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> failed.
6766
/// </summary>
68-
/// <param name="error">The error.</param>
67+
/// <param name="error">The error.</param>
6968
public static void RemoteNotificationRegistrationFailed(NSError error)
7069
{
7170
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
@@ -76,22 +75,22 @@ public static void RemoteNotificationRegistrationFailed(NSError error)
7675
/// </summary>
7776
/// <param name="center">The shared user notification center object that received the notification.</param>
7877
/// <param name="response">The user's response to the notification.</param>
79-
/// <param name="completionHandler">The action to execute when you have finished processing the user's response.</param>
80-
public static void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
81-
{
82-
NotifoIO.DidReceiveNotificationResponse(center, response, completionHandler);
83-
84-
if (CrossFirebasePushNotification.Current is IUNUserNotificationCenterDelegate notificationDelegate)
85-
{
86-
notificationDelegate.DidReceiveNotificationResponse(center, response, completionHandler);
87-
}
88-
}
89-
90-
private static bool ContainsPullRefreshRequest(NSDictionary data)
91-
{
92-
var aps = data?.ObjectForKey(new NSString(Constants.ApsKey)) as NSDictionary;
93-
94-
return aps != null && aps.ContainsKey(new NSString(Constants.ContentAvailableKey));
95-
}
96-
}
97-
}
78+
/// <param name="completionHandler">The action to execute when you have finished processing the user's response.</param>
79+
public static void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
80+
{
81+
NotifoIO.DidReceiveNotificationResponse(center, response, completionHandler);
82+
83+
if (CrossFirebasePushNotification.Current is IUNUserNotificationCenterDelegate notificationDelegate)
84+
{
85+
notificationDelegate.DidReceiveNotificationResponse(center, response, completionHandler);
86+
}
87+
}
88+
89+
private static bool ContainsPullRefreshRequest(NSDictionary data)
90+
{
91+
var aps = data?.ObjectForKey(new NSString(Constants.ApsKey)) as NSDictionary;
92+
93+
return aps != null && aps.ContainsKey(new NSString(Constants.ContentAvailableKey));
94+
}
95+
}
96+
}

sdk/Notifo.SDK.FirebasePlugin/NotifoPushNotificationHandler.android.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Notifo.SDK.NotifoMobilePush;
1313
using Notifo.SDK.Resources;
1414
using Plugin.FirebasePushNotification;
15-
using Serilog;
1615

1716
namespace Notifo.SDK.FirebasePlugin
1817
{
@@ -27,7 +26,7 @@ public NotifoPushNotificationHandler()
2726

2827
public override void OnReceived(IDictionary<string, object> parameters)
2928
{
30-
Log.Debug(Strings.ReceivedNotification, parameters);
29+
NotifoIO.Current.RaiseDebug(Strings.ReceivedNotification, this, parameters);
3130

3231
var notification = new UserNotificationDto()
3332
.FromDictionary(new Dictionary<string, object>(parameters));

sdk/Notifo.SDK.FirebasePlugin/PluginEventsProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class PluginEventsProvider : IPushEventsProvider
2222

2323
public event EventHandler<Notifo.SDK.NotificationEventArgs> OnNotificationOpened;
2424

25-
public event EventHandler<Notifo.SDK.NotificationErrorEventArgs> OnError;
25+
public event EventHandler<Notifo.SDK.NotificationLogEventArgs> OnLog;
2626

2727
public PluginEventsProvider()
2828
{
@@ -39,7 +39,7 @@ private void FirebasePushNotification_OnTokenRefresh(object source, FirebasePush
3939

4040
private void Current_OnNotificationError(object source, FirebasePushNotificationErrorEventArgs e)
4141
{
42-
OnError?.Invoke(this, new NotificationErrorEventArgs(e.Message, null, source));
42+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, source, e.Message, null, null));
4343
}
4444

4545
private void FirebasePushNotification_OnNotificationReceived(object source, FirebasePushNotificationDataEventArgs e)

sdk/Notifo.SDK/CommandQueue/DefaultCommandQueue.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal sealed class DefaultCommandQueue : ICommandQueue
2727
private readonly BlockingCollection<QueuedCommand> queue = new BlockingCollection<QueuedCommand>();
2828
private readonly Queue<QueuedCommand> retryQueue = new Queue<QueuedCommand>();
2929

30-
public event EventHandler<NotificationErrorEventArgs> OnError;
30+
public event EventHandler<NotificationLogEventArgs> OnLog;
3131

3232
public DefaultCommandQueue(
3333
ICommandStore commandStore,
@@ -104,7 +104,7 @@ private async Task StoreAsync(QueuedCommand queudCommand)
104104
}
105105
catch (Exception ex)
106106
{
107-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
107+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
108108
}
109109
}
110110

@@ -132,7 +132,7 @@ private async Task RunAsync()
132132
}
133133
catch (Exception ex)
134134
{
135-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
135+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
136136
}
137137

138138
foreach (var trigger in commandTriggers)
@@ -165,7 +165,7 @@ private async Task RunAsync()
165165
}
166166
catch (Exception ex)
167167
{
168-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
168+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
169169
}
170170

171171
// We have just completed a command, so it is very likely that the next one will be successful as well.

sdk/Notifo.SDK/CommandQueue/ICommandQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Notifo.SDK.CommandQueue
1313
{
1414
internal interface ICommandQueue
1515
{
16-
event EventHandler<NotificationErrorEventArgs> OnError;
16+
event EventHandler<NotificationLogEventArgs> OnLog;
1717

1818
void Run(ICommand command);
1919

0 commit comments

Comments
 (0)