Skip to content

Commit 36eaf09

Browse files
Log decoding errors.
1 parent 5054b4c commit 36eaf09

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public override void OnReceived(IDictionary<string, object> parameters)
4040
if (parameters.TryGetValue(IdKey, out var id))
4141
{
4242
var notificationId = Math.Abs(id.GetHashCode());
43+
4344
parameters[IdKey] = notificationId;
4445
}
4546

sdk/Notifo.SDK/Extensions/StringExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public static string AppendQueries(this string url, string? key1, object? value1
4343
}
4444

4545
public static string AppendQueries(this string url, string? key1, object? value1, string? key2, object? value2)
46+
{
47+
return AppendQueries(url, key1, value1, key2, value2, null!, null!);
48+
}
49+
50+
public static string AppendQueries(this string url, string? key1, object? value1, string? key2, object? value2, string? key3, object? value3)
4651
{
4752
if (string.IsNullOrWhiteSpace(url))
4853
{
@@ -80,6 +85,7 @@ void Append(string? key, object? value)
8085

8186
Append(key1, value1);
8287
Append(key2, value2);
88+
Append(key3, value3);
8389

8490
return builder.ToString();
8591
}

sdk/Notifo.SDK/NotifoMobilePush/NotifoMobilePushImplementation.android.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,34 @@ internal void OnBuildNotification(NotificationCompat.Builder notificationBuilder
9292
notificationHandler?.OnBuildNotification(notificationBuilder, notification);
9393
}
9494

95-
private Bitmap? GetBitmap(string bitmapUrl, int width = -1, int height = -1)
95+
private Bitmap? GetBitmap(string bitmapUrl, int? width = null, int? height = null)
9696
{
9797
try
9898
{
9999
// Let the server resize the image to the perfect format.
100-
bitmapUrl = bitmapUrl.AppendQueries("width", width, "height", height);
100+
if (width != null && height != null)
101+
{
102+
bitmapUrl = bitmapUrl.AppendQueries("width", width, "height", height);
103+
}
101104

102105
if (bitmapCache.TryGetValue(bitmapUrl, out Bitmap cachedBitmap))
103106
{
104107
return cachedBitmap;
105108
}
106109

107110
var bitmapStream = new URL(bitmapUrl)?.OpenConnection()?.InputStream;
111+
var bitmapImage = BitmapFactory.DecodeStream(bitmapStream);
108112

109-
var bitmap = BitmapFactory.DecodeStream(bitmapStream);
110-
if (bitmap != null)
113+
if (bitmapImage != null)
114+
{
115+
bitmapCache.Set(bitmapUrl, bitmapImage);
116+
}
117+
else
111118
{
112-
bitmapCache.Set(bitmapUrl, bitmap);
119+
NotifoIO.Current.RaiseError(Strings.DecodingImageError, null, this);
113120
}
114121

115-
return bitmap;
122+
return bitmapImage;
116123
}
117124
catch (Exception ex)
118125
{

sdk/Notifo.SDK/Resources/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/Notifo.SDK/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
<data name="CommandError" xml:space="preserve">
121121
<value>Command queue has thrown an error.</value>
122122
</data>
123+
<data name="DecodingImageError" xml:space="preserve">
124+
<value>Could not decode image.</value>
125+
</data>
123126
<data name="DownloadImageError" xml:space="preserve">
124127
<value>Could not download image.</value>
125128
</data>

0 commit comments

Comments
 (0)