Skip to content

Commit 6afba7f

Browse files
Merge pull request #11 from notifo-io/fallback-tracking
Fallback tracking
2 parents b644e28 + 91d4261 commit 6afba7f

35 files changed

+501
-583
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</ItemGroup>
5454

5555
<ItemGroup>
56-
<PackageReference Include="Notifo.SDK" Version="1.5.1" />
56+
<PackageReference Include="Notifo.SDK" Version="1.6.4" />
5757
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
5858
</ItemGroup>
5959

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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ namespace Notifo.SDK.FirebasePlugin
1717
internal class PluginEventsProvider : IPushEventsProvider
1818
{
1919
public event EventHandler<TokenRefreshEventArgs> OnTokenRefresh;
20+
2021
public event EventHandler<Notifo.SDK.NotificationEventArgs> OnNotificationReceived;
22+
2123
public event EventHandler<Notifo.SDK.NotificationEventArgs> OnNotificationOpened;
22-
public event EventHandler<Notifo.SDK.NotificationErrorEventArgs> OnError;
24+
25+
public event EventHandler<Notifo.SDK.NotificationLogEventArgs> OnLog;
2326

2427
public PluginEventsProvider()
2528
{
@@ -36,7 +39,7 @@ private void FirebasePushNotification_OnTokenRefresh(object source, FirebasePush
3639

3740
private void Current_OnNotificationError(object source, FirebasePushNotificationErrorEventArgs e)
3841
{
39-
OnError?.Invoke(this, new NotificationErrorEventArgs(e.Message, null, source));
42+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, source, e.Message, null, null));
4043
}
4144

4245
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
@@ -26,7 +26,7 @@ internal sealed class DefaultCommandQueue : ICommandQueue
2626
private readonly BlockingCollection<QueuedCommand> queue = new BlockingCollection<QueuedCommand>();
2727
private readonly Queue<QueuedCommand> retryQueue = new Queue<QueuedCommand>();
2828

29-
public event EventHandler<NotificationErrorEventArgs> OnError;
29+
public event EventHandler<NotificationLogEventArgs> OnLog;
3030

3131
public DefaultCommandQueue(
3232
ICommandStore commandStore,
@@ -88,7 +88,7 @@ private async Task StoreAsync(QueuedCommand queudCommand)
8888
}
8989
catch (Exception ex)
9090
{
91-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
91+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
9292
}
9393
}
9494

@@ -116,7 +116,7 @@ private async Task RunAsync()
116116
}
117117
catch (Exception ex)
118118
{
119-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
119+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
120120
}
121121

122122
foreach (var trigger in commandTriggers)
@@ -149,7 +149,7 @@ private async Task RunAsync()
149149
}
150150
catch (Exception ex)
151151
{
152-
OnError?.Invoke(this, new NotificationErrorEventArgs(Strings.CommandError, ex, this));
152+
OnLog?.Invoke(this, new NotificationLogEventArgs(NotificationLogType.Error, this, Strings.CommandError, null, ex));
153153
}
154154

155155
// 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
@@ -11,7 +11,7 @@ namespace Notifo.SDK.CommandQueue
1111
{
1212
internal interface ICommandQueue
1313
{
14-
event EventHandler<NotificationErrorEventArgs> OnError;
14+
event EventHandler<NotificationLogEventArgs> OnLog;
1515

1616
void Run(ICommand command);
1717

0 commit comments

Comments
 (0)