Skip to content

Commit 0ecf300

Browse files
committed
Added ClearBadgeCounter for iOS
1 parent ded507b commit 0ecf300

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

Assets/_PackageRoot/Scripts/MobileNotifications.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public static void CancelAllScheduled()
3838
MobileNotifications_Android.CancelAllScheduled();
3939
#elif UNITY_IOS
4040
MobileNotifications_iOS.CancelAllScheduled();
41+
#endif
42+
}
43+
44+
public static void ClearBadgeCounteriOS()
45+
{
46+
if (Config.debug)
47+
Debug.Log($"MobileNotifications.ClearBadgeCounteriOS");
48+
49+
#if UNITY_IOS
50+
MobileNotifications_iOS.ClearBadgeCounter();
4151
#endif
4252
}
4353
}

Assets/_PackageRoot/Scripts/iOS/MobileNotifications_iOS.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ public static async UniTask RequestAuthorization()
2121
await UniTask.Yield();
2222
};
2323

24-
string res = "RequestAuthorization:";
25-
res += "\n finished: " + req.IsFinished;
26-
res += "\n granted : " + req.Granted;
27-
res += "\n error: " + req.Error;
28-
res += "\n deviceToken: " + req.DeviceToken;
29-
Debug.Log(res);
24+
if (NotificationsInitializer.Config.debug)
25+
{
26+
string res = "RequestAuthorization:";
27+
res += "\n finished: " + req.IsFinished;
28+
res += "\n granted : " + req.Granted;
29+
res += "\n error: " + req.Error;
30+
res += "\n deviceToken: " + req.DeviceToken;
31+
Debug.Log(res);
32+
}
3033
}
3134
}
3235
private static async UniTask RegisterNotificationChannel(string identifier, string title, string subtitle, string body, iOSNotificationTrigger trigger)
@@ -84,6 +87,10 @@ public static void CancelAllScheduled()
8487
{
8588
iOSNotificationCenter.RemoveAllScheduledNotifications();
8689
}
90+
public static void ClearBadgeCounter()
91+
{
92+
iOSNotificationCenter.ApplicationBadge = 0;
93+
}
8794
}
8895
}
8996
#endif

Assets/_PackageRoot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "extensions.unity.notifications",
33
"displayName": "Unity Notifications",
44
"author": { "name": "Ivan Murzak", "url": "https://github.com/IvanMurzak" },
5-
"version": "1.0.8",
5+
"version": "1.1.0",
66
"unity": "2019.2",
77
"description": "Unity Mobile Notifications integration.",
88
"dependencies": {

Packages/manifest.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"dependencies": {
3-
"com.unity.ide.visualstudio": "2.0.12",
4-
"com.unity.ide.vscode": "1.2.4",
3+
"com.cysharp.unitask": "2.2.5",
4+
"com.unity.ide.visualstudio": "2.0.14",
5+
"com.unity.ide.vscode": "1.2.5",
56
"com.unity.mobile.notifications": "1.4.2",
6-
"com.unity.test-framework": "1.1.30",
7+
"com.unity.test-framework": "1.1.31",
78
"com.unity.ugui": "1.0.0",
8-
"com.cysharp.unitask": "2.2.5",
99
"com.unity.modules.ai": "1.0.0",
1010
"com.unity.modules.androidjni": "1.0.0",
1111
"com.unity.modules.animation": "1.0.0",
@@ -43,15 +43,15 @@
4343
"name": "Unity Extensions",
4444
"url": "https://registry.npmjs.org",
4545
"scopes": [
46-
"extensions.unity"
46+
"extensions.unity"
4747
]
4848
},
4949
{
5050
"name": "NPM",
5151
"url": "https://registry.npmjs.org",
5252
"scopes": [
53-
"com.cysharp",
54-
"com.neuecc"
53+
"com.cysharp",
54+
"com.neuecc"
5555
]
5656
}
5757
]

Packages/packages-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"url": "https://packages.unity.com"
1616
},
1717
"com.unity.ide.visualstudio": {
18-
"version": "2.0.12",
18+
"version": "2.0.14",
1919
"depth": 0,
2020
"source": "registry",
2121
"dependencies": {
@@ -24,7 +24,7 @@
2424
"url": "https://packages.unity.com"
2525
},
2626
"com.unity.ide.vscode": {
27-
"version": "1.2.4",
27+
"version": "1.2.5",
2828
"depth": 0,
2929
"source": "registry",
3030
"dependencies": {},
@@ -40,7 +40,7 @@
4040
"url": "https://packages.unity.com"
4141
},
4242
"com.unity.test-framework": {
43-
"version": "1.1.30",
43+
"version": "1.1.31",
4444
"depth": 0,
4545
"source": "registry",
4646
"dependencies": {

0 commit comments

Comments
 (0)