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 ;
15
14
using UserNotifications ;
16
-
17
- namespace Notifo . SDK . FirebasePlugin
15
+
16
+ namespace Notifo . SDK . FirebasePlugin
18
17
{
19
18
/// <summary>
20
19
/// Plugin initialization.
21
- /// </summary>
22
- public class NotifoFirebasePlugin
23
- {
20
+ /// </summary>
21
+ public class NotifoFirebasePlugin
22
+ {
24
23
/// <summary>
25
24
/// Initializes the firebase plugin.
26
25
/// </summary>
27
26
/// <param name="options">Application launch options.</param>
28
27
/// <param name="notifoStartup">The <see cref="INotifoStartup"/> implementation.</param>
29
28
/// <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
+
39
38
/// <summary>
40
39
/// Invoked when the application received a remote notification.
41
40
/// </summary>
42
41
/// <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
+
56
55
/// <summary>
57
56
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> succeeded.
58
57
/// </summary>
59
- /// <param name="deviceToken">The device token.</param>
58
+ /// <param name="deviceToken">The device token.</param>
60
59
public static void DidRegisterRemoteNotifications ( NSData deviceToken )
61
60
{
62
61
FirebasePushNotificationManager . DidRegisterRemoteNotifications ( deviceToken ) ;
@@ -65,7 +64,7 @@ public static void DidRegisterRemoteNotifications(NSData deviceToken)
65
64
/// <summary>
66
65
/// Indicates that a call to <see cref="UIKit.UIApplication.RegisterForRemoteNotifications"/> failed.
67
66
/// </summary>
68
- /// <param name="error">The error.</param>
67
+ /// <param name="error">The error.</param>
69
68
public static void RemoteNotificationRegistrationFailed ( NSError error )
70
69
{
71
70
FirebasePushNotificationManager . RemoteNotificationRegistrationFailed ( error ) ;
@@ -76,22 +75,22 @@ public static void RemoteNotificationRegistrationFailed(NSError error)
76
75
/// </summary>
77
76
/// <param name="center">The shared user notification center object that received the notification.</param>
78
77
/// <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
+ }
0 commit comments