Skip to content

Commit fc9c3a9

Browse files
committed
bug fixes
1 parent fd8e342 commit fc9c3a9

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

Directory.build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<RepositoryUrl>https://github.com/CrossGeeks/FirebasePushNotificationPlugin</RepositoryUrl>
1919
<RepositoryType>git</RepositoryType>
2020
<Product>$(AssemblyName) ($(TargetFramework))</Product>
21-
<Version>3.2.0</Version>
21+
<Version>3.3.0</Version>
2222

2323
<!--<Nullable>enable</Nullable>-->
2424
<LangVersion>8.0</LangVersion>

Plugin.FirebasePushNotification/FirebasePushNotificationManager.ios.cs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Plugin.FirebasePushNotification/Plugin.FirebasePushNotification.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@
108108
<AndroidResource Include="Resources\**\*.json" Generator="MSBuild:UpdateAndroidResources" />
109109
<Compile Include="**\*.android.cs" />
110110
<Compile Include="**\*.android.*.cs" />
111+
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
111112
<PackageReference Include="Xamarin.Firebase.Common" Version="71.1610.0" />
112113
<PackageReference Include="Xamarin.Firebase.Messaging" Version="71.1740.0" />
114+
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1610.0" />
113115
<PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="71.1620.0" />
114116
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="71.1601.0" />
115-
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
117+
116118
</ItemGroup>
117119

118120
<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen')) ">

0 commit comments

Comments
 (0)