windows7lake / app_badge_plus

A Flutter plugin for adding badges to your app icon.
MIT License
16 stars 6 forks source link

isSupport Feature #3

Closed utkudenis closed 3 months ago

utkudenis commented 4 months ago

Hi Developer,

Can you add isSupported feature(Especially for android) like discontiuned package of flutter_app_badger.

windows7lake commented 4 months ago

@utkudenis Add 'isSupported' to check if launcher supports badge counter. But actually, updateBadge will do nothing when the launcher doesn't support badge counter. I think it is unnecessary to check if the launcher support badge counter. version: 1.1.0

utkudenis commented 4 months ago

As I checked from package, there is an exception if it is not implemented

windows7lake commented 4 months ago

Could you pls tell me which exception it will throw? Any detail?

utkudenis commented 4 months ago

Future updateBadge(int count) { throw UnimplementedError('updateBadge() has not been implemented.'); }

lib/app_badge_plus_platform_interface.dart

I thought that if platform support does not implemented , it will throw this error.

However, your first comment was nothing happen if platfrom does not supported.

windows7lake commented 4 months ago

flutter will invoke native api, which has been implement in android and ios. So it will not throw UnimplementedError when you are using android or iOS devices.

creativecreatorormaybenot commented 4 months ago

@windows7lake I see that the latest version now has an isSupported method. Why did you decide to implement it after all?

Is it still safe to call updateBadgeCount without checking isSupported first on Android and iOS?

windows7lake commented 4 months ago

@creativecreatorormaybenot It always return true on iOS, and on Android it will return false if the launcher doesn't support badge.

creativecreatorormaybenot commented 4 months ago

@windows7lake But it is safe to call updateBadgeCount without checking first on Android?

windows7lake commented 4 months ago

@creativecreatorormaybenot Yes, try catch the exception and print log to console but do nothing.

creativecreatorormaybenot commented 4 months ago

@windows7lake So you are saying I need to wrap the updateBadgeCount in a try / catch block manually?

windows7lake commented 4 months ago

@creativecreatorormaybenot No, I have been deal with it in native, you dont need to do anything, just use the api.