Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] AppIcon Badge #807

Closed
8 tasks
VladislavAntonyuk opened this issue Dec 3, 2022 · 5 comments · Fixed by #1126
Closed
8 tasks

[Proposal] AppIcon Badge #807

VladislavAntonyuk opened this issue Dec 3, 2022 · 5 comments · Fixed by #1126
Assignees
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature documentation approved proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail

Comments

@VladislavAntonyuk
Copy link
Collaborator

VladislavAntonyuk commented Dec 3, 2022

Feature name

AppIconBadge

Link to discussion

#734

Progress tracker

  • Android Implementation
  • iOS Implementation
  • MacCatalyst Implementation
  • Windows Implementation
  • Tizen Implementation
  • Unit Tests
  • Samples
  • Documentation

Summary

Screenshot 2022-11-07 at 13 46 05

Notify the user about some action in the application.

Step by step with output screenshots at https://vladislavantonyuk.azurewebsites.net/articles/AppIcon-Badge-with-.NET-MAUI

Motivation

Better user experience and app interaction with OS.

https://developer.apple.com/documentation/uikit/uiapplication/1622918-applicationiconbadgenumber
https://github.com/leolin310148/ShortcutBadger

Detailed Design

public interface INotificationCounter
{
	Task<bool> RequestPermission();
	void SetNotificationCount(int count);
}

Usage Syntax

var isGranted = await NotificationCounter.Default.RequestPermission();
if (isGranted)
    NotificationCounter.Default.SetNotificationCount(count);

Drawbacks

Android implementation requires the support of many launchers. As part of this feature, I suggest creating a base class and implementation for some main providers, because we can't support all launchers

Alternatives

No response

Unresolved Questions

No response

@VladislavAntonyuk VladislavAntonyuk added new proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail labels Dec 3, 2022
@ghost ghost added this to Proposal Submitted in New Feature Proposals Dec 3, 2022
@VladislavAntonyuk VladislavAntonyuk self-assigned this Dec 3, 2022
@LennoxP90
Copy link

https://github.com/alexrainman/Badge

@brminnick brminnick moved this from Proposal Submitted to Proposal Championed in New Feature Proposals Dec 13, 2022
@ghost ghost added champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature and removed new labels Dec 13, 2022
@brminnick
Copy link
Collaborator

Thanks @VladislavAntonyuk!

Promoting to approved This Proposal has been approved and is ready to be added to the Toolkit as we voted to approve it in the December Standup.

Technically, we should've opened the Proposal first before voting to approve said Proposal, but we'll let this one slide.

Submitting a Proposal doesn't require a vote from the core maintainers. It should start as a Discussion, and then once the Discussion is deemed feature-complete a Proposal can be opened.

@brminnick brminnick moved this from Proposal Championed to Proposal Approved in New Feature Proposals Dec 13, 2022
@ghost ghost added approved This Proposal has been approved and is ready to be added to the Toolkit help wanted This proposal has been approved and is ready to be implemented labels Dec 13, 2022
@KSemenenko
Copy link
Member

I love this porposal =)

@VladislavAntonyuk
Copy link
Collaborator Author

@KSemenenko we are focusing on bug fixes for the next month or two. however I am going to implement it as a next feature PR.

VladislavAntonyuk added a commit that referenced this issue Apr 3, 2023
brminnick added a commit that referenced this issue Jul 23, 2023
* BadgeCounter #807

* Rename to Badge

* Update tests

* Remove Xamarin.Android.ShortcutBadger dependency

* Fix Tizen build

* Add default badge provider, add nova

* Fix SamsungBadgeProvider

* SetProvider

* Initialize array only once

* `dotnet format`

* Update SamsungBadgeProvider.cs

* Update BadgeViewModel.cs

* Update DefaultBadgeProvider.android.cs

* Use `Lazy<T>` to ensure thread safety

* GetCount

- Uncommented lines in the csproj file to address Android App installation failure.

Toggle Home Screen Icon Badge Count

- Added column and row spacing to improve layout in the BadgePage.xaml file.

SetBadgeProvider method update

- Renamed SetProvider method to SetBadgeProvider in the BadgeFactory.android.cs file.

GetCount method implementation

- Implemented GetCount method in the BadgeImplementation.android.cs, DefaultBadgeProvider.android.cs, BadgeImplementation.macios.cs, and BadgeImplementation.tizen.cs files.

Added GetCount method to IBadge interface

- Added GetCount method to the IBadge.shared.cs file.

* feat: Add support for Samsung badge provider

This commit adds support for the Samsung badge provider in the Android platform. It includes changes to the `SamsungBadgeProvider` class and the `DefaultBadgeProvider.android.cs` file.

- Added a new static readonly string array `packageNameArray` in the `SamsungBadgeProvider` class.
- Modified the `SetCount` method in the `SamsungBadgeProvider` class to use `packageNameArray` instead of directly passing a string array.
- Added a new method `GetCount()` in the `SamsungBadgeProvider` class.
- Renamed the method `IsSupported()` to `CanSetBadgeCounter()` in the `DefaultBadgeProvider.android.cs` file.
- Added debug log statements for error handling scenarios in both classes.

* Fix SamsungBadgeProvider.cs and BadgeTests.cs

- Fix a typo in SamsungBadgeProvider.cs by changing "new[1]" to "new string[1]"
- Add a new test method GetBadgeFailsOnNet() in BadgeTests.cs that tests the behavior of getting badge count on .NET platform
- Modify the existing test method SetBadgeFailsOnNet() in BadgeTests.cs to throw NotSupportedException instead of NotImplementedException
- Add a new method GetCount() in BadgeImplementationMock.cs that throws NotImplementedException

* Fix build error

Sorry Vlad - this was my fault!

* Update CommunityToolkit.Maui.Sample.csproj

* Update DefaultBadgeProvider.android.cs

* Update BadgeImplementation.macios.cs

* Update EssentialsGalleryViewModel.cs

* Update BaseGalleryViewModel.cs

* Update MainApplication.cs

* Add null check

* Remove `count` field

* Update DefaultBadgeProvider.android.cs

* Add additional text explaining Bade

* Remove GetCount, use uint instead of int

* fix tizen build

* Update src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.windows.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Update src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.tizen.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Update src/CommunityToolkit.Maui.Core/Essentials/Badge/Android/BadgeFactory.android.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Update src/CommunityToolkit.Maui.Core/Essentials/Badge/Android/DefaultBadgeProvider.android.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

---------

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
@ghost ghost reopened this Jul 23, 2023
@ghost
Copy link

ghost commented Jul 23, 2023

Reopening Proposal.

Only Proposals moved to the Closed Project Column and Completed Project Column can be closed.

@brminnick brminnick moved this from Proposal Approved to Pull Request Approved (Pending Documentation) in New Feature Proposals Jul 23, 2023
@brminnick brminnick removed the help wanted This proposal has been approved and is ready to be implemented label Jul 23, 2023
@brminnick brminnick moved this from Pull Request Approved (Pending Documentation) to Documentation Approved in New Feature Proposals Aug 9, 2023
@brminnick brminnick moved this from Documentation Approved to Completed in New Feature Proposals Aug 9, 2023
@ghost ghost closed this as completed Aug 9, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This Proposal has been approved and is ready to be added to the Toolkit champion A member of the .NET MAUI Toolkit core team has chosen to champion this feature documentation approved proposal A fully fleshed out proposal describing a new feature in syntactic and semantic detail
Projects
Development

Successfully merging a pull request may close this issue.

4 participants