Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android notifications. testing guideline


Published on

You'll find out about testing push notifications on Android. Here you'll see a little bit of code, a lot of Android features and bugs and advises how to handle them.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Android notifications. testing guideline

  1. 1. Android Notifications. Testing guideline By Lera Stadnyk
  2. 2. Notification is a message you can display to any user outside of your app. You’ve probably seen and heard them after a day with device turned off =) Implementation Notification.Builder class that issues notifications was added to Android OS in 3.0 (API lvl 11). Design Design described in Material Design Guide since v.5.0 (API 21). By the way, till 5.0 Lollipop icons on notifications were colored. They are black’n’white now by default. To make them colored we change targetSdkVersion in gradle to 19.
  3. 3. Receiving notifications+test - potential issues ●Notification was received after each action, not after 1st as it was intended. ●Notification can be received by forbidden users - blocked, guests, wrong users. ●Notification comes only to devices where app is open (active). ●Staging N can be received on production server. ●Notifications received after leaving an app+logging out. ●Duplicated N were sent to user. ●N may be received out of time (too early, too late). Critical in games! ●Missing N on the lock screen on Android 5.0 Lollipop. ●Huawei and Xiaomi devices have evil task killer services that interfere with notification service. In order for notifications to work, users need to add the app to allowed apps in those devices' security settings. Huawei: Phone Manager App > Protected apps > Add app to the list. Xiaomi: Services > Security > Permissions > Autostart (or Settings -> Permissions > Autostart on new devices ), find app and enable autostart. Let the users know that. ●User can not receives pushes with full memory/cache. ●On some devices (e.g. Moto g 2) using them with guest user may interfere N receiving. ●Ns may not work at all on OS lower than v.4.4.4. on Nexus 5. ●Receiving a Notification may crash your app.
  4. 4. Content of Notification Notification Object that we pass via code to Android OS must contain: - small icon. - title. - details text. Otherwise, notifications won't work correctly: white square will be shown instead on icon, system text or empty space will appear, Notification may crash the app etc. Possible issues: ● few different N received in a row may have the same content. ● if 2 N were received one by one 2nd may override the 1st ones content. ● icon may be grey, not colored. ● wrong content may be received.
  5. 5. Notification actions Actions are optional, but Android forces developers to add at least 1 action - that one that allows user to go directly from notification to some Activity in the app. As notification can provide multiple actions, tap on Notification should always be defined. Other actions are optional and may be associated with some gesture via special method from NotificationCompat.Builder class. Actions: tap, dismissing a N., long tap etc.
  6. 6. Notification actions: test ● Tap. ● Tap after logout. ● Tap being logged in via another user. ● Tap without any Internet connection. ● Maximize/minimize the app with notification being in N. panel. ● Block the screen of the app with notification being in N. panel. ● Tap on any link inside/outside the app. ● Send a N. to few devices at the same time (< 3 if you use Firebase).
  7. 7. Notification actions: Potential bugs ● Wrong requests go to server after tap on N. ● Tap on the N redirects user to the wrong place/ does not redirect him at all. ● N received after not intended action. ● User can access forbidden screen by tap on N. ● App crashes if we tapped on N after logout+killing the app. ● Wrong data comes from the server after tap on N + login in the app: empty screen or screen filled with other users data (cookies to blame). ● Some functionality may be blocked after opening the app from Notification. ● App opens up by itself after minimizing if there is notification in N panel. ● App crashes after deleting the N.
  8. 8. Buttons Buttons are actually a good way to provide user a way to choose between few actions without opening an app. Buttons were added in Android 4.1. Buttons testing ● Tap on each one individually. ● Tap on both of them at the same time. ● Check if action provided by button was really done. ● Check the data sent via using a button. ● Tap with WiFi turned off. ● For actions that can’t be repeated, check if button become locked.
  9. 9. Expanded layout Expanded layout became available on Android 4.2 and higher. The way it is created: ● Сreate normal notification object. ● Сall .setStyle() method with expanded argument. Expanded layout testing Our notification: ● Can be expanded/closed for a few times. ● Can be opened from normal/expanded view. ● Disappears after tap. ● Looks normal after closing/opening expansion panel again. ● Acts OK on Android 4.1 and lower.
  10. 10. Notifications Priority is a hint to UI of device about when and how display the Notification. The higher the priority set, the more interruptive will be the Notification. There are: ● Max (for critical and urgent events). ● High (important like chat messages). ● Default (for n. That don’t fall into other categories). ● Low (relevant but not urgent events). ● Min (nice-to-know background info). Priority sets by developer. Please pay attention that only HIGH/MAX priority notifications will be received in the Doze (energy saving) mode on 6.0 (shey should wake up device) and NO notification at all will be received in that mode on 7.0. This behavior can be perfectly seen with Notifications sent via Google Cloud Messaging.
  11. 11. Notification stacking is a feature made to avoid creating many notifications of the same type. Instead, if stacking used: ● The same notification updates. ● Counter appears. ● Summary of each event appears on the notification.
  12. 12. Notification stacking: test To test stacking, check: ● Notifications stacked at number of 2 and higher. ● Amount of events = amount of stacked notifications. ● Notification counter number = amount of stacked notifications. ● Counter does not change after opening/closing expansion panel. ● Create 5, 10, 100 events to check the UI. ● Expand/close the panel. ● Check stack reaction to different actions. ● Lock/unlock the screen with notification panel open.
  13. 13. Notification visibility / removing + test Notification will remain visible until: ● User dismisses it manually or with “Clear all” button. ● User taps on notification (programmer called setAutoCancel() method when created Notification). ● Cancel() method called for specific notification ID which can delete ongoing notification (with progress). ● CancelAll() method called that removes all the notifications. To test it you: ● Dismiss Ns 1 by 1 or with “Clear all”. ● Tap on N and look if it is dismissed. ● Delete N with progress bar.
  14. 14. Replying to Notification Starting in Android 7.0 (API 24) user can respond to message from notification. After entering the text keyboard sends it to messaging app. Developer can also add messaging/chat history to this notification. Android OS forces developers to update or cancel Notification after app received remote input from N. But Android users guideline suggests that if user replies to remote update using Direct Reply (in app), that Notification should be updated with the reply, not cancelled.
  15. 15. Replying to Notification: test ● Check if Notification updated. ● Check if your data transferred to the server. ● Notification reply has the same validation as reply in the app. ● Notification reply should accept special symbols, emoji. ● Reply was send correct times and to correct user. ● Empty replay wasn’t send to user if we tapped Reply and closed/deleted the N. ● Try to reply with no Internet connection. ● Lock/unlock the screen while typing. ● Maximize/minimize the app while typing.
  16. 16. Notification Bundling In Android 7.0 (API 24) new representation of N queue appeared. Now notifications sent from from 1 source will be bundled as a group. To make this real developer should use Builder. setGroup() method. Bundling (shows full notification) is similar to stacking (shows event summary only).
  17. 17. Notification Bundling Group imposes a hierarchy on the N: ● Parent notification on the top. ● Expand the bundle to see all the children notification content. ● Expand child to see only its content. If group was not specified by developer and app sends few notifications, Android OS will put them together into 1 bundle.
  18. 18. Notification Bundling: test ● Send few similar notifications of 1 type. ● Send few notifications of different types. ● Check the maximum size of notification showing and try to exceed the limit. ● Check if bundled notification was correctly updated if it has the opportunity to reply. ● Bundled notifications should have the same functionality as single ones. ● Send 5, 10, 50, 100 notifications of the same type to check if any limits or graphical issues appearing.
  19. 19. Progress in Notifications (ongoing notification) Notification can include an animated progress indicator. ● If you can estimate how long the operation takes and how much of it is completed in any time, use progress bar (determinate form). Percentage can be added here. ● If you can’t estimate how long operation takes, use an activity indicator (indeterminate form). 1. Progress bar. 2. Activity indicator. 3. Activity indicator.
  20. 20. Progress in Notifications (ongoing notification) When the operation is done, progress bar can be: ● Left with according text. ● Removed. Activity indicator always needs to be removed. Test it: ● Thread.sleep is between the progress bar updating, so try to interrupt progress to find the crash. ● See if indicators are gone after process they displaying is done. ● Tap on the ongoing N. ● Try to dismiss it/look if process wasn’t stopped, only N disappeared. ● Try interruptions while progress bar is moving.
  21. 21. Preserving navigation If Activity was started from the Notification, users expected navigation behavior must be preserved. It means that if user taps Back button he goes back through apps normal work flow to the Home screen. Test it going back after each action: ● Tap on the notification from the different place and tap Back. ● Block the screen and put the app into background after tap on N, then tap back. ● Turn on Dev options - No background processes + Don’t keep activities, tap Back(catch nullpointerexception). ● Tangle your tracks - try to go different ways and use tangled flows. But notice - preserved navigations should be created for regular activity. If user can
  22. 22. Heads-up notifications After Android 5.0 (API lvl 21) N can appears as a small floating window when the device is active. Their difference from a compact form is ability to contain buttons.
  23. 23. Lock screen Notifications After Android 5.0 (API lvl 21) Notification may appear on the lock screen (it’s on but locked). To display it choose a corresponding option in Settings. Test it: ● Tap on the Notification. ● On some devices notifications are not shown on block screen at all. ● On other devices notification may be seen on the block screen even if the corresponding option in Setting is off. ● There is pretty rare special Android issue when Notification seeing on the block screen disappears from device at all after unlocking the screen - it counts as seen and deleted.
  24. 24. How I tested Rewards Notifications Below you can see my standard test cases set for rewards notification functionality. I created cases based on their functionality as we can receive them (1st section), we can work with them (2nd one) and we can do other different actions (3rd one). I’m pretty sure that this amount of cases will cover enough to find almost all the possible issues. Also our actions are somehow combined during testing process and there are many workarounds can be found. I also used 2 platforms and 4 devices to test Ns for friends functionality as we created Ns via Firebase: it send Ns to 3 devices max at the same time.
  25. 25. Firebase as our Notification provider We choose Firebase to make our notifications. Ex Google cloud messaging = Firebase now. It is official Google service. Firebase has cool SDK and easy to set up and run. For more information about Firebase please visit