Push notifications are clickable pop-up messages that appear on the user’s device as a way of intimating the user about some information. Messages are sent from the mobile app to the user’s phone screen. To view this notification, the user should have installed the app on the mobile. Thus, push notifications to serve as a quick communication channel to alert the user which he otherwise would get to know only once he navigates to the App.
In this article, we will see how to achieve Push Notifications in the mobile Power App so that we can send notifications to the user’s mobile screen from the app.
We will take the Medicine Inventory Demo app where we use it to track incoming medicine stock as well as outgoing medicine requests. In the case of an Outgoing medicine request, some of the medicines like Morphine may fall under the sensitive category, and taking it out of the stock would require an intimation to the medical supervisor. To achieve this, we will provide an option to check if the medicine being taken out belongs to a specific restricted category and if yes, we will be sending a Push Notification to the supervisor while checking out the medicine.
To achieve Push Notifications, we can either invoke Power Automate to use the Power Apps Push Notification action, or else we can add a connection to the Push Notification connector natively in Power App, so as to initiate the Push Notification directly from the Power App. In this sample we will see how to achieve Push Notifications directly from Power App, however, if you have more additional logic that needs to be completed before sending Push Notifications, Power Automate could be a more viable option.
To do this let’s head over to the App from which we want to initiate the Push Notification. From File ->Settings->Support->Session Details- Select the App ID
We can also get the App ID from the Details section of the App from the App List
Once we have the App ID, let’s head over to the Data tab in the left pane and create a connection to the Power Apps Notification V2 Connector
We will then add the below expression in the Pull Stock button that will save the outgoing stock details to the SharePoint List. We have added the usual patch function to save the data and in addition to that, we have also added a conditional check to see if the Drug belongs to a specific category of drugs. If Yes, we will send the Push Notification to the Supervisor.
If(Checkbox_ScheduleH.Value = true,
“A new Schedule H drug (“&TextInput_Medicine.Text&”) has been taken out of the Inventory. For more details, please visit the Medicine Inventory List “,
The Syntax for Push Notification is as below
We have the flexibility to pass parameters to Power App as a key value pair
When the user clicks on the Notification, it will pass the parameter and open the App. Inside the App, we can consume this value just like we access the Query String using the Param function and Navigate to the corresponding screen.
Same way, we can pass any specific records the user has to see bypassing the record ID and opening the record using the ID when the user clicks on the Push Notification.
Now let’s test the push notification by previewing the app and adding an outgoing medical record entry
This has saved the records to the SharePoint List and sent out a Push notification to the user on his/her mobile device
Thus, we saw how to create a Push Notification to a Mobile Device from Power App so as to intimate the user with some app-specific information that will need his attention.