cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nigel_s
Advocate I
Advocate I

OnVisible not triggered by Push Notification

I have a phone app into which users enter data a couple of times a day. I send a Push Notification if they've missed an entry. When they click the notification I want to open the app and take them directly to the Add Record screen. If the app is closed, OnStart triggers and everything works fine, but if it's still loaded (but not visible on the phone), the notification makes the app visible but neither OnStart nor OnVisible is fired. I understand OnStart not firing but OnVisible not firing, seems wrong. The screen is not visible and making the app active, makes it visible.

 

If OnVisible fired, I could handle the notification's action there but it doesn't and I can't. I can't think of a way to correctly respond to the notification. The users are entering data frequently and so it's likely the app will still be loaded.

1 ACCEPTED SOLUTION

Accepted Solutions

I got this to work by sending a parameter, paramPushTime from the Flow, set to the current time. I also created a variable varPushTime, which I set to the current time when the app opens. If a notification opens the app, the parameter paramPushTime will be set. When + is pressed to create a record, I compare varPushTime to paramPushTime, and if they're not the same I set the data entry defaults to the param. In the OnSuccess event, I update the varPushTime to the paramPushTime so it won't trigger the next time + is pressed.

Now I think the problem is if the app is never closed and another notification is sent and pushed, the parameter is not updated. Which doesn't totally surprise me because parameters seem to be read-only. Time for a new thread...

View solution in original post

9 REPLIES 9
Eelman
Super User
Super User

@nigel_s 

I've not used the notifications feature but the MS documentation talks about setting a blank landing page with a Timer. Then use OnTimerEnd to Navigate to the screen you want. This may work?

 

Here's the link, see towards the bottom

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/add-notifications

 

Let me know how you get on

Hi,

 

Thanks for your response. I read that and added a LoadingPage but deleted it because it's like everything else. If a notification opens a loaded app, neither App.OnStart, a loading page or OnVisible is triggered. It just shows the page which was showing when it went into the background. I don't know if there is an event somewhere which is triggered but I haven't found it. 😞

 

@nigel_s 

No easy solution I guess, unless someone else has solved it?

 

You could force users back to a Main Page/Screen after submitting data which has 'Enter app' & 'Exit app' options. That way if they just hit [for example] the iOS Home button to exit it won't matter because when they re-open the app it'll be on the Main page screen. They'd then select 'Enter app' to start re-entering data and you could run OnVisible once they do?

 

Just an idea?

Yes, I had thought of that as an option, I'm just a bit short on time to get that wired and tested - needing to get my first app out fast for tracking things related to the corona virus.

 

The only drawback is I can't automatically take the user to the Add New Record screen automatically.

 

The overall problem is a bit like the designer, if you're editing a screen and press Play, that page becomes live but OnVisible isn't fired (as far as I can see). Same kind of thing, my exception with that is, the app is hidden and OnVisible should fire.

Re this:

"The only drawback is I can't automatically take the user to the Add New Record screen automatically."

 

Could you not just Navigate to a screen after they do some action / click a button / press submit / etc?

 

 

Yes, that is correct but I've got two questions.

 

The notification passes a Param, varOpenedFromPush = true - which I would use to know the apps been opened by a notification - and some other details as defaults to create a new record. I'm thinking that if varOpenedFromPush is true I open the Add details screen (if I'm not already there).

 

Would that mean I need to trap every OnSelect/OnVisible event to check varOpenedFromPush? Is there a way to centralize the logic which would realize that the app's responded to a Push Notification? Otherwise, that's a DRY fail.

 

The other thing I'm not sure about is, once I've handled that event, how do I turn it off? I don't think you can update a Param. So the code which checks for the Param could never turn the notification off and every click would be hijacked from that point forward.

Re Question 1, how is Add a Record completed by the user? If I assume it's the same as the simple 3-screen app that PowerApps builds for you could navigate users to a Main Screen after select the tick. Without any details about how your app works I can't fully answer this question.

 

If the above would works, I can't see the need for a param, unless you are recording it in a DB somewhere?

Hi @nigel_s ,

Actually, the OnVisible property of app screen would be fired only when you navigate from another screen to current screen, or when you run your app from closed status.

 

In addition, you could only receive the Push Notification in your mobile device when the PowerApps Mobile App is in background or in closed state.

 

If you want to pass a varOpenedFromPush variable to your canvas app, you need to trap every OnSelect/OnVisible event to check varOpenedFromPush variable. Currently, there is no way to centralize the logic which would realize that the app's responded to a Push Notification.

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

For your second question, do you want to turn off the PowerApps Push Notification? Currently, there is no way or function supported to turn off the PowerApps Push Notification in PowerApps currently.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I got this to work by sending a parameter, paramPushTime from the Flow, set to the current time. I also created a variable varPushTime, which I set to the current time when the app opens. If a notification opens the app, the parameter paramPushTime will be set. When + is pressed to create a record, I compare varPushTime to paramPushTime, and if they're not the same I set the data entry defaults to the param. In the OnSuccess event, I update the varPushTime to the paramPushTime so it won't trigger the next time + is pressed.

Now I think the problem is if the app is never closed and another notification is sent and pushed, the parameter is not updated. Which doesn't totally surprise me because parameters seem to be read-only. Time for a new thread...

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,092)