Skip to content

Commit

Permalink
Add support for setting badge count using UNUserNotificationCenter … (
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavAntonyuk authored Nov 16, 2023
1 parent c5daa10 commit dfe3022
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public void SetCount(uint count)
}
});

UIApplication.SharedApplication.ApplicationIconBadgeNumber = (int)count;
if (OperatingSystem.IsIOSVersionAtLeast(17))
{
UNUserNotificationCenter.Current.SetBadgeCount(new IntPtr((int)count), (error) =>
{
if (error is not null)
{
Trace.WriteLine($"Error setting the Badge Count: {error.Description}");
}
});
}
else
{
UIApplication.SharedApplication.ApplicationIconBadgeNumber = (int)count;
}
}
}

0 comments on commit dfe3022

Please sign in to comment.