@@ -139,19 +139,30 @@ public static void Initialize(NSDictionary options, bool autoRegistration = true
139139
140140 CrossFirebasePushNotification . Current . NotificationHandler = CrossFirebasePushNotification . Current . NotificationHandler ?? new DefaultPushNotificationHandler ( ) ;
141141 Messaging . SharedInstance . AutoInitEnabled = autoRegistration ;
142- if ( autoRegistration )
142+
143+ if ( options ? . ContainsKey ( UIApplication . LaunchOptionsRemoteNotificationKey ) ?? false )
143144 {
144- CrossFirebasePushNotification . Current . RegisterForPushNotifications ( ) ;
145- }
145+ var pushPayload = options [ UIApplication . LaunchOptionsRemoteNotificationKey ] as NSDictionary ;
146+ if ( pushPayload != null )
147+ {
148+ var parameters = GetParameters ( pushPayload ) ;
146149
150+ var notificationResponse = new NotificationResponse ( parameters , string . Empty , NotificationCategoryType . Default ) ;
147151
148- /*if (options != null && options.Keys != null && options.Keys.Count() != 0 && options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")))
149- {
150- NSDictionary data = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary;
151152
152- // CrossFirebasePushNotification.Current.OnNotificationOpened(GetParameters(data));
153+ /*if (_onNotificationOpened == null && enableDelayedResponse)
154+ delayedNotificationResponse = notificationResponse;
155+ else*/
156+ _onNotificationOpened ? . Invoke ( CrossFirebasePushNotification . Current , new FirebasePushNotificationResponseEventArgs ( notificationResponse . Data , notificationResponse . Identifier , notificationResponse . Type ) ) ;
153157
154- }*/
158+ CrossFirebasePushNotification . Current . NotificationHandler ? . OnOpened ( notificationResponse ) ;
159+ }
160+ }
161+
162+ if ( autoRegistration )
163+ {
164+ CrossFirebasePushNotification . Current . RegisterForPushNotifications ( ) ;
165+ }
155166
156167 }
157168 public static void Initialize ( NSDictionary options , IPushNotificationHandler pushNotificationHandler , bool autoRegistration = true )
@@ -236,7 +247,7 @@ public void RegisterForPushNotifications()
236247
237248 Messaging . SharedInstance . Delegate = CrossFirebasePushNotification . Current as IMessagingDelegate ;
238249
239- Messaging . SharedInstance . ShouldEstablishDirectChannel = true ;
250+ // Messaging.SharedInstance.ShouldEstablishDirectChannel = true;
240251
241252 // Register your app for remote notifications.
242253 if ( UIDevice . CurrentDevice . CheckSystemVersion ( 10 , 0 ) )
@@ -283,7 +294,7 @@ public void UnregisterForPushNotifications()
283294 if ( hasToken )
284295 {
285296 CrossFirebasePushNotification . Current . UnsubscribeAll ( ) ;
286- Messaging . SharedInstance . ShouldEstablishDirectChannel = false ;
297+ // Messaging.SharedInstance.ShouldEstablishDirectChannel = false;
287298 hasToken = false ;
288299 // Disconnect();
289300 }
@@ -476,13 +487,16 @@ public void SendDeviceGroupMessage(IDictionary<string, string> parameters, strin
476487 {
477488 if ( hasToken )
478489 {
479- var message = new NSMutableDictionary ( ) ;
480- foreach ( var p in parameters )
490+ using ( var message = new NSMutableDictionary ( ) )
481491 {
482- message . Add ( new NSString ( p . Key ) , new NSString ( p . Value ) ) ;
483- }
492+ foreach ( var p in parameters )
493+ {
494+ message . Add ( new NSString ( p . Key ) , new NSString ( p . Value ) ) ;
495+ }
484496
485- Messaging . SharedInstance . SendMessage ( message , groupKey , messageId , timeOfLive ) ;
497+ Messaging . SharedInstance . SendMessage ( message , groupKey , messageId , timeOfLive ) ;
498+ }
499+
486500 }
487501 }
488502
0 commit comments