Issue
There are lots Huawei icon badges related threads in SO, like How to show App Icon Badge Numbers on Huawei, and I have read the official document of Badges.
I do think the official documents are good enough, I just want to know how may we test it automatically?
For example, if one of the engineers in the team who mis-config the config the Badge-related SDK files, customers' Huawei phone would still able to push the notification, but the Badge number might not show.
I believe the image classification tech would help, like, we could test it automatically in the following way:
- Install the app and login the app by adb shell command + uiautomator
- Back the home screen in order to view the icon
- Push notifications from backend server.
- Screenshot the phone, and use some deep learning tech image classification to verify if there's Badge numbers on it.
It may not the best way to test it in these steps, I was wondering if maybe there is any native API to fetch the badge numbers?
Solution
The best way to find this kind of information is to look for open source apps, like settings or launcher apps:
If you want to verify whether notification badges or on or off you can do:
Settings.Secure.getInt(context.contentResolver, "notification_badging")
This is even documented in the Settings
class, but the setting name (Settings.Secure.NOTIFICATION_BADGING
) is part of the hidden (internal) API. But still it works, at least it does for stock Android. For Huawei devices you'll have to test by yourself.
For obtaining the badge count, I don't know if it can be directly obtained. From the second link above, it seems you have to make a notification listener to count incoming notifications.
Answered By - Nicolas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.