-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: Add a possibility to listen to system notifications #50
Conversation
Okay. will do 👌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a couple of typographical issues.
README.md
Outdated
## Notifications | ||
|
||
Since version 2.16.0 Appium Settings supports retrieval of system notifications. | ||
You need to manually switch the corresponding security switcher next to `Appium Setitngs` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appium Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
README.md
Outdated
``` | ||
The notifications listener service is running in the background and collects | ||
all the active and newly created notifications into the internal buffer with maximum | ||
size of `100`. The collected data (e. g. the properties and texts of each notification) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g.,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems very cool. how would the uiautomator2 server retrieve the notifications from the settings app?
via adb broadcast. I'll prepare a PR to appium-adb after this one is published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried once. It worked on my device like below
Broadcast completed: result=-1, data="{"statusBarNotifications":[{"packageName":"io.appium.settings","isClearable":false,"isOngoing":true,"id":1,"tag":null,"postTime":1576894156718,"isRemoved":false,"notification":{"title":null,"bigTitle":"Appium Settings","text":null,"bigText":"Keep this service running, so Appium for Android can properly interact with several system APIs","tickerText":null,"subText":null,"infoText":null,"template":"android.app.Notification$BigTextStyle"},"isGroup":false,"userHandle":0,"groupKey":"0|io.appium.settings|1|null|10428","overrideGroupKey":null,"key":"0|io.appium.settings|1|null|10428"},{"packageName":"android","isClearable":false,"isOngoing":true,"id":26,"tag":null,"postTime":1576894142111,"isRemoved":false,"notification":{"title":"USB debugging connected","bigTitle":null,"text":"Tap to turn off USB debugging","bigText":null,"tickerText":null,"subText":null,"infoText":null,"template":null},"isGroup":false,"userHandle":-1,"groupKey":"-1|android|26|null|1000","overrideGroupKey":null,"key":"-1|android|26|null|1000"},{"packageName":"com.airvisual","isClearable":false,"isOngoing":true,"id":200000,"tag":null,"postTime":1576891008899,"isRemoved":false,"notification":{"title":null,"bigTitle":null,"text":null,"bigText":null,"tickerText":null,"subText":null,"infoText":null,"template":null},"isGroup":true,"userHandle":0,"groupKey":"0|com.airvisual|g:nearest","overrideGroupKey":null,"key":"0|com.airvisual|200000|null|10292"},{"packageName":"android","isClearable":false,"isOngoing":true,"id":32,"tag":null,"postTime":1576894142108,"isRemoved":false,"notification":{"title":"Charging this device via USB","bigTitle":null,"text":"Tap for more options.","bigText":null,"tickerText":null,"subText":null,"infoText":null,"template":null},"isGroup":false,"userHandle":-1,"groupKey":"-1|android|32|null|1000","overrideGroupKey":null,"key":"-1|android|32|null|1000"}]}"
|
||
Since version 2.16.0 Appium Settings supports retrieval of system notifications. | ||
You need to manually switch the corresponding security switcher next to `Appium Settings` | ||
application name in `Settings->Notification Access` (the path to this page under Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Note for Android 9 (Android One, Nokia)
Settings > App & Notifications > special app access > Notification access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my Samsung it's different ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Tell me please, how can I grant permission for get status bar notifications via adb? Is it available?
@@ -5,7 +5,7 @@ android { | |||
buildToolsVersion '28.0.3' | |||
|
|||
defaultConfig { | |||
minSdkVersion 17 | |||
minSdkVersion 18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, NotificationListenerService
requires this version 👀
We should bump http://appium.io/docs/en/about-appium/platform-support/ from 4.2 to 4.3 after introducing this.
It is safe to merge this after Appium 1.16.0 release and bump this major version to 3, I believe.
(Or not to bump current 1.16.0 release candidate to this merged version.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we need to bump the major version.
@imurchie Any chance to release appium 1.16 soon?
Log.e(TAG, result); | ||
} | ||
setResultCode(Activity.RESULT_OK); | ||
setResultData(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should here return the error message as JSON format since maybe UIA2 will parse the result as JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the output will be parsed by appium-adb
I would say it is fine to return it as string - JSON we only get in case of "green path".
Thanks for help @KazuCocoa 🙇 |
9d6c3b1
to
96baa11
Compare
96baa11
to
11620bf
Compare
Sometimes it might be useful to automate a scenario in Android whether the app under test received push notifications and verify their content. The PR makes it possible, although it is necessary to manually allow Appium Settings the access to system notifications. I think this should not be too hard, since we never delete this app with Appium, but only upgrade it if necessary, which means the system settings for it stay untouched.
@KazuCocoa Could you please assist with testing on real devices?