Skip to content

Commit 4bb7cf1

Browse files
Merge pull request #2 from CoderGamester/develop
Release 0.1.2
2 parents e3d4df3 + abce6fd commit 4bb7cf1

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.1.2] - 2020-07-29
8+
9+
**Fixed**:
10+
- Fixed notification channel for Android
11+
712
## [0.1.1] - 2020-07-29
813

914
**Fixed**:

Runtime/Android/AndroidNotificationsPlatform.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if UNITY_ANDROID
22
using System;
3+
using System.Linq;
34
using Unity.Notifications.Android;
45

56
// ReSharper disable once CheckNamespace
@@ -29,6 +30,31 @@ public AndroidNotificationsPlatform()
2930
AndroidNotificationCenter.OnNotificationReceived += OnLocalNotificationReceived;
3031
}
3132

33+
/// <summary>
34+
/// Registers the given <seealso cref="AndroidNotificationChannel"/> for the Android
35+
/// </summary>
36+
public void RegisterChannel(GameNotificationChannel notificationChannel)
37+
{
38+
long[] vibrationPattern = null;
39+
if (notificationChannel.VibrationPattern != null)
40+
{
41+
vibrationPattern = notificationChannel.VibrationPattern.Select(v => (long)v).ToArray();
42+
}
43+
44+
var channel = new AndroidNotificationChannel(notificationChannel.Id, notificationChannel.Name,
45+
notificationChannel.Description, (Importance)notificationChannel.Style)
46+
{
47+
CanBypassDnd = notificationChannel.HighPriority,
48+
CanShowBadge = notificationChannel.ShowsBadge,
49+
EnableLights = notificationChannel.ShowLights,
50+
EnableVibration = notificationChannel.Vibrates,
51+
LockScreenVisibility = (LockScreenVisibility)notificationChannel.Privacy,
52+
VibrationPattern = vibrationPattern
53+
};
54+
55+
AndroidNotificationCenter.RegisterNotificationChannel(channel);
56+
}
57+
3258
/// <inheritdoc />
3359
/// <remarks>
3460
/// Will set the <see cref="AndroidGameNotification.Id"/> field of <paramref name="gameNotification"/>.

Runtime/GameNotificationsMonoBehaviour.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -309,35 +309,17 @@ public void Initialize(params GameNotificationChannel[] channels)
309309

310310
// Register the notification channels
311311
var doneDefault = false;
312-
foreach (GameNotificationChannel notificationChannel in channels)
312+
foreach (var notificationChannel in channels)
313313
{
314+
var platform = _platform as AndroidNotificationsPlatform;
315+
314316
if (!doneDefault)
315317
{
316318
doneDefault = true;
317-
((AndroidNotificationsPlatform)_platform).DefaultChannelId = notificationChannel.Id;
319+
platform.DefaultChannelId = notificationChannel.Id;
318320
}
319321

320-
long[] vibrationPattern = null;
321-
if (notificationChannel.VibrationPattern != null)
322-
{
323-
vibrationPattern = notificationChannel.VibrationPattern.Select(v => (long)v).ToArray();
324-
}
325-
326-
// Wrap channel in Android object
327-
var androidChannel = new AndroidNotificationChannel(
328-
notificationChannel.Id, notificationChannel.Name,
329-
notificationChannel.Description,
330-
(Importance)notificationChannel.Style)
331-
{
332-
CanBypassDnd = notificationChannel.HighPriority,
333-
CanShowBadge = notificationChannel.ShowsBadge,
334-
EnableLights = notificationChannel.ShowLights,
335-
EnableVibration = notificationChannel.Vibrates,
336-
LockScreenVisibility = (LockScreenVisibility)notificationChannel.Privacy,
337-
VibrationPattern = vibrationPattern
338-
};
339-
340-
AndroidNotificationCenter.RegisterNotificationChannel(androidChannel);
322+
platform.RegisterChannel(notificationChannel);
341323
}
342324
#elif UNITY_IOS
343325
_platform = new iOSNotificationsPlatform();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.gamelovers.notificationservice",
33
"displayName": "Notification Service",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"unity": "2019.4",
66
"description": "This package provides an easier to use service to help manage the notification sent to mobile devices, and based on the Unity's Mobile Notifications package.\nIt allows to schedule local notifications, receive remote notifications and clear any type of notification.",
77
"dependencies": {

0 commit comments

Comments
 (0)