0

So what I want to achieve is notify the user whenever a new order is received by showing a pop up at the top of the screen with a custom dialog to accept/cancel the order. This pop up should open even if the app is not running.

Order notifications are received through FCM and captured in onMessageReceived of FCM.

I am able to show notifications and play custom notification sound but I am not able to find a way in which I can show the pop up(Custom Dialog) to the user.

User states can be:

  1. Phone locked and kept idle
  2. May be on a call
  3. Using another app
  4. Using the same app but still show the pop up

So I want the order pop up to be the highest priority so that it either gets accepted/cancelled within seconds the customer has ordered

  • 1
    You need permission SYSTEM_ALERT_WINDOW. That allows you to draw on top of other apps. Please note that on each device the user will need to whitelist your app for that permission, Until the user whitelists you, you won't be displayed. – Gabe Sechan Apr 16 '22 at 08:47
  • @HarshPalit you may get detailed answer here. https://stackoverflow.com/questions/32558153/how-to-make-alertdialog-view-in-input-method-service/52902433#52902433 – Bhoomika Patel Apr 16 '22 at 09:28
  • @GabeSechan thanks for your support. The user will whitelist the app as its for business purposes – Harsh Palit Apr 17 '22 at 16:04
  • @BhoomikaPatel, thanks for the reference. I went through the code and are you referring to this part of the code? if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); }else{ alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); } – Harsh Palit Apr 17 '22 at 16:05

0 Answers0