Skip to content

Commit 5b21679

Browse files
Implicit usings and namespace fix
1 parent fce328d commit 5b21679

File tree

75 files changed

+4075
-4241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4075
-4241
lines changed

sample/Sample/Sample.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
55
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
6+
<TargetFramework>netstandard2.1</TargetFramework>
67
</PropertyGroup>
78

89
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

sample/Sample/ViewModels/EventsPageViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// All rights reserved. Licensed under the MIT license.
66
// ==========================================================================
77

8-
using System;
98
using System.Diagnostics;
109
using MvvmHelpers;
1110
using Notifo.SDK;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<Project Sdk="MSBuild.Sdk.Extras/3.0.22">
22

33
<PropertyGroup>
4-
<NoWarn>CS1591;CS0618</NoWarn>
4+
<NoWarn>CS1591;CS0618</NoWarn>
55
<AssemblyName>Notifo.Xamarin.FirebasePlugin</AssemblyName>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
8+
<ImplicitUsings>enable</ImplicitUsings>
89
<LangVersion>latest</LangVersion>
910
<PackageId>Notifo.Xamarin.Firebase</PackageId>
1011
<RootNamespace>Notifo.SDK.FirebasePlugin</RootNamespace>

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

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,37 @@
1010
using Plugin.FirebasePushNotification;
1111
using Notifo.SDK;
1212

13-
namespace Notifo.SDK.FirebasePlugin
13+
namespace Notifo.SDK.FirebasePlugin;
14+
15+
/// <summary>
16+
/// Plugin initialization.
17+
/// </summary>
18+
public class NotifoFirebasePlugin
1419
{
1520
/// <summary>
16-
/// Plugin initialization.
21+
/// Initializes the firebase plugin.
1722
/// </summary>
18-
public class NotifoFirebasePlugin
23+
/// <param name="context">The current application context.</param>
24+
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
25+
/// <param name="notificationHandler">The <see cref="INotificationHandler"/> implementation.</param>
26+
/// <param name="resetToken">Set to <see langword="true"/> while debugging.</param>
27+
/// <param name="autoRegistration">Automatically register for push notifications.</param>
28+
public static void Initialize(Context context, INotifoStartup notifoStartup, INotificationHandler notificationHandler = null, bool resetToken = false, bool autoRegistration = true)
1929
{
20-
/// <summary>
21-
/// Initializes the firebase plugin.
22-
/// </summary>
23-
/// <param name="context">The current application context.</param>
24-
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
25-
/// <param name="notificationHandler">The <see cref="INotificationHandler"/> implementation.</param>
26-
/// <param name="resetToken">Set to <see langword="true"/> while debugging.</param>
27-
/// <param name="autoRegistration">Automatically register for push notifications.</param>
28-
public static void Initialize(Context context, INotifoStartup notifoStartup, INotificationHandler notificationHandler = null, bool resetToken = false, bool autoRegistration = true)
29-
{
30-
FirebasePushNotificationManager.Initialize(context, new NotifoPushNotificationHandler(), resetToken, createDefaultNotificationChannel: true, autoRegistration);
30+
FirebasePushNotificationManager.Initialize(context, new NotifoPushNotificationHandler(), resetToken, createDefaultNotificationChannel: true, autoRegistration);
3131

32-
NotifoIO.Current.SetNotificationHandler(notificationHandler);
33-
notifoStartup.ConfigureService(NotifoIO.Current);
34-
}
32+
NotifoIO.Current.SetNotificationHandler(notificationHandler);
33+
notifoStartup.ConfigureService(NotifoIO.Current);
34+
}
3535

36-
/// <summary>
37-
/// Method for processing open notification intent.
38-
/// </summary>
39-
/// <param name="activity">The current activity.</param>
40-
/// <param name="intent">The intent for processing.</param>
41-
public static void ProcessIntent(Activity activity, Intent intent)
42-
{
43-
FirebasePushNotificationManager.ProcessIntent(activity, intent, enableDelayedResponse: true);
44-
NotifoIO.Current.UseFirebasePluginEventsProvider();
45-
}
36+
/// <summary>
37+
/// Method for processing open notification intent.
38+
/// </summary>
39+
/// <param name="activity">The current activity.</param>
40+
/// <param name="intent">The intent for processing.</param>
41+
public static void ProcessIntent(Activity activity, Intent intent)
42+
{
43+
FirebasePushNotificationManager.ProcessIntent(activity, intent, enableDelayedResponse: true);
44+
NotifoIO.Current.UseFirebasePluginEventsProvider();
4645
}
4746
}

sdk/Notifo.SDK.FirebasePlugin/NotifoFirebasePlugin.ios.cs

Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,84 +13,83 @@
1313
using Plugin.FirebasePushNotification;
1414
using UserNotifications;
1515

16-
namespace Notifo.SDK.FirebasePlugin
16+
namespace Notifo.SDK.FirebasePlugin;
17+
18+
/// <summary>
19+
/// Plugin initialization.
20+
/// </summary>
21+
public class NotifoFirebasePlugin
1722
{
1823
/// <summary>
19-
/// Plugin initialization.
24+
/// Initializes the firebase plugin.
2025
/// </summary>
21-
public class NotifoFirebasePlugin
26+
/// <param name="options">Application launch options.</param>
27+
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
28+
/// <param name="notificationHandler">The <see cref="INotificationHandler"/> implementation.</param>
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)
2231
{
23-
/// <summary>
24-
/// Initializes the firebase plugin.
25-
/// </summary>
26-
/// <param name="options">Application launch options.</param>
27-
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
28-
/// <param name="notificationHandler">The <see cref="INotificationHandler"/> implementation.</param>
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);
32+
FirebasePushNotificationManager.Initialize(options, autoRegistration);
3333

34-
NotifoIO.Current.SetNotificationHandler(notificationHandler);
35-
notifoStartup.ConfigureService(NotifoIO.Current);
36-
}
34+
NotifoIO.Current.SetNotificationHandler(notificationHandler);
35+
notifoStartup.ConfigureService(NotifoIO.Current);
36+
}
37+
38+
/// <summary>
39+
/// Invoked when the application received a remote notification.
40+
/// </summary>
41+
/// <param name="data">The notification data dictionary.</param>
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);
3746

38-
/// <summary>
39-
/// Invoked when the application received a remote notification.
40-
/// </summary>
41-
/// <param name="data">The notification data dictionary.</param>
42-
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
43-
public static async Task DidReceiveMessageAsync(NSDictionary data)
47+
if (ContainsPullRefreshRequest(data))
4448
{
45-
NotifoIO.Current.RaiseDebug(Strings.ReceivedNotification, null, data);
49+
await NotifoIO.DidReceivePullRefreshRequestAsync();
50+
}
4651

47-
if (ContainsPullRefreshRequest(data))
48-
{
49-
await NotifoIO.DidReceivePullRefreshRequestAsync();
50-
}
52+
FirebasePushNotificationManager.DidReceiveMessage(data);
53+
}
5154

52-
FirebasePushNotificationManager.DidReceiveMessage(data);
53-
}
55+
/// <summary>
56+
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> succeeded.
57+
/// </summary>
58+
/// <param name="deviceToken">The device token.</param>
59+
public static void DidRegisterRemoteNotifications(NSData deviceToken)
60+
{
61+
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
62+
}
5463

55-
/// <summary>
56-
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> succeeded.
57-
/// </summary>
58-
/// <param name="deviceToken">The device token.</param>
59-
public static void DidRegisterRemoteNotifications(NSData deviceToken)
60-
{
61-
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
62-
}
64+
/// <summary>
65+
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> failed.
66+
/// </summary>
67+
/// <param name="error">The error.</param>
68+
public static void RemoteNotificationRegistrationFailed(NSError error)
69+
{
70+
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
71+
}
6372

64-
/// <summary>
65-
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> failed.
66-
/// </summary>
67-
/// <param name="error">The error.</param>
68-
public static void RemoteNotificationRegistrationFailed(NSError error)
69-
{
70-
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
71-
}
73+
/// <summary>
74+
/// Method for processing the user's response to a delivered notification.
75+
/// </summary>
76+
/// <param name="center">The shared user notification center object that received the notification.</param>
77+
/// <param name="response">The user's response to the notification.</param>
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);
7282

73-
/// <summary>
74-
/// Method for processing the user's response to a delivered notification.
75-
/// </summary>
76-
/// <param name="center">The shared user notification center object that received the notification.</param>
77-
/// <param name="response">The user's response to the notification.</param>
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)
83+
if (CrossFirebasePushNotification.Current is IUNUserNotificationCenterDelegate notificationDelegate)
8084
{
81-
NotifoIO.DidReceiveNotificationResponse(center, response, completionHandler);
82-
83-
if (CrossFirebasePushNotification.Current is IUNUserNotificationCenterDelegate notificationDelegate)
84-
{
85-
notificationDelegate.DidReceiveNotificationResponse(center, response, completionHandler);
86-
}
85+
notificationDelegate.DidReceiveNotificationResponse(center, response, completionHandler);
8786
}
87+
}
8888

89-
private static bool ContainsPullRefreshRequest(NSDictionary data)
90-
{
91-
var aps = data?.ObjectForKey(new NSString(Constants.ApsKey)) as NSDictionary;
89+
private static bool ContainsPullRefreshRequest(NSDictionary data)
90+
{
91+
var aps = data?.ObjectForKey(new NSString(Constants.ApsKey)) as NSDictionary;
9292

93-
return aps != null && aps.ContainsKey(new NSString(Constants.ContentAvailableKey));
94-
}
93+
return aps != null && aps.ContainsKey(new NSString(Constants.ContentAvailableKey));
9594
}
9695
}

sdk/Notifo.SDK.FirebasePlugin/NotifoMobilePushExtensions.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,23 @@
1010
using Notifo.SDK.NotifoMobilePush;
1111
using Notifo.SDK.PushEventProvider;
1212

13-
namespace Notifo.SDK.FirebasePlugin
13+
namespace Notifo.SDK.FirebasePlugin;
14+
15+
/// <summary>
16+
/// The <see cref="INotifoMobilePush"/> extension methods.
17+
/// </summary>
18+
public static class NotifoMobilePushExtensions
1419
{
20+
private static readonly Lazy<IPushEventsProvider> CurrentPluginEventsProvider =
21+
new Lazy<IPushEventsProvider>(() => new PluginEventsProvider(), LazyThreadSafetyMode.PublicationOnly);
22+
1523
/// <summary>
16-
/// The <see cref="INotifoMobilePush"/> extension methods.
24+
/// Use the firebase plugin as the push events provider.
1725
/// </summary>
18-
public static class NotifoMobilePushExtensions
26+
/// <param name="notifoMobilePush">The <see cref="INotifoMobilePush"/> instance.</param>
27+
/// <returns>The current instance.</returns>
28+
public static INotifoMobilePush UseFirebasePluginEventsProvider(this INotifoMobilePush notifoMobilePush)
1929
{
20-
private static readonly Lazy<IPushEventsProvider> CurrentPluginEventsProvider =
21-
new Lazy<IPushEventsProvider>(() => new PluginEventsProvider(), LazyThreadSafetyMode.PublicationOnly);
22-
23-
/// <summary>
24-
/// Use the firebase plugin as the push events provider.
25-
/// </summary>
26-
/// <param name="notifoMobilePush">The <see cref="INotifoMobilePush"/> instance.</param>
27-
/// <returns>The current instance.</returns>
28-
public static INotifoMobilePush UseFirebasePluginEventsProvider(this INotifoMobilePush notifoMobilePush)
29-
{
30-
return notifoMobilePush.SetPushEventsProvider(CurrentPluginEventsProvider.Value);
31-
}
30+
return notifoMobilePush.SetPushEventsProvider(CurrentPluginEventsProvider.Value);
3231
}
3332
}

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,44 @@
1313
using Notifo.SDK.Resources;
1414
using Plugin.FirebasePushNotification;
1515

16-
namespace Notifo.SDK.FirebasePlugin
16+
namespace Notifo.SDK.FirebasePlugin;
17+
18+
internal class NotifoPushNotificationHandler : DefaultPushNotificationHandler
1719
{
18-
internal class NotifoPushNotificationHandler : DefaultPushNotificationHandler
20+
private NotifoMobilePushImplementation notifoMobilePush;
21+
22+
public NotifoPushNotificationHandler()
23+
{
24+
notifoMobilePush = (NotifoMobilePushImplementation)NotifoIO.Current;
25+
}
26+
27+
public override void OnReceived(IDictionary<string, object> parameters)
1928
{
20-
private NotifoMobilePushImplementation notifoMobilePush;
29+
NotifoIO.Current.RaiseDebug(Strings.ReceivedNotification, this, parameters);
30+
31+
var notification = new UserNotificationDto()
32+
.FromDictionary(new Dictionary<string, object>(parameters));
2133

22-
public NotifoPushNotificationHandler()
34+
if (notification.Silent)
2335
{
24-
notifoMobilePush = (NotifoMobilePushImplementation)NotifoIO.Current;
36+
return;
2537
}
2638

27-
public override void OnReceived(IDictionary<string, object> parameters)
39+
if (parameters.TryGetValue(IdKey, out var id))
2840
{
29-
NotifoIO.Current.RaiseDebug(Strings.ReceivedNotification, this, parameters);
30-
31-
var notification = new UserNotificationDto()
32-
.FromDictionary(new Dictionary<string, object>(parameters));
33-
34-
if (notification.Silent)
35-
{
36-
return;
37-
}
41+
var notificationId = Math.Abs(id.GetHashCode());
3842

39-
if (parameters.TryGetValue(IdKey, out var id))
40-
{
41-
var notificationId = Math.Abs(id.GetHashCode());
42-
43-
parameters[IdKey] = notificationId;
44-
}
45-
46-
base.OnReceived(parameters);
43+
parameters[IdKey] = notificationId;
4744
}
4845

49-
public override void OnBuildNotification(NotificationCompat.Builder notificationBuilder, IDictionary<string, object> parameters)
50-
{
51-
var notification = new UserNotificationDto()
52-
.FromDictionary(new Dictionary<string, object>(parameters));
46+
base.OnReceived(parameters);
47+
}
5348

54-
notifoMobilePush.OnBuildNotification(notificationBuilder, notification);
55-
}
49+
public override void OnBuildNotification(NotificationCompat.Builder notificationBuilder, IDictionary<string, object> parameters)
50+
{
51+
var notification = new UserNotificationDto()
52+
.FromDictionary(new Dictionary<string, object>(parameters));
53+
54+
notifoMobilePush.OnBuildNotification(notificationBuilder, notification);
5655
}
5756
}

0 commit comments

Comments
 (0)