Windows Phone 8.1 Silverlight - Toast Notification Launch Causes App to Restart - c#

I'm working on Toast Notifications for my WP8.1 Silverlight App that are activated via a background process. Whenever I tap on the Toast when it appears (or tap on it from the Notification Action Center), it always restarts the app. It navigates to the main page for a split-second and I notice that the Bing Map I have embedded in the Mainpage is blank, then it restarts. I specify in the toast for it to go to the mainpage as follows (with a parameter):
((XmlElement)toastNode).SetAttribute("launch", "#/MainPage.xaml?conversation=12345");
Other aberrant behavior is
When debugging, and the app is invoked from the Toast the main page 'onNavigatedTo' event gets hit twice both times with the parameter specified from the toast.
When the app relaunches itself after being invoked from the Toast, and I go back to the Start Screen and tap the Live Tile to be taken back to the app, it again needs to restart itself. This never happens if I launch the app normally from the Live Tile or Application Icon.
The debugger isn't catching anything. Could it be something to do with the app being tombstoned, or the app 'Applicated_Activated' event not being hit up properly?

Related

OnSuspending event fired during app initialization while minimized

I have a UWP app that is configured to auto start at Windows boot via the Startup Apps on Windows 11.
On some PCs - and it is unclear for what configurations - the app starts minimized at Windows boot, and receives a OnSuspending event while it is still initializing (during or just after the OnNavigatedTo event, and before the OnLaunched event). This OnSuspending event breaks the initialization sequence of the app which keeps running but fails to execute its task.
So a successful sequence of events looks like:
OnActivated
OnNavigatedTo
OnBackgroundActivated
A failing sequence looks like:
OnActivated
OnNavigatedTo
OnSuspending
OnBackgroundActivated
I can't see on my code any logic error that would lead to this OnSuspending event. Is there a possibility that Windows sends this event out of the blue at this boot time, maybe depending on other processes being started at the same time? Or should I look further in my code for any error that leads to this suspension?
OnSuspending event fired during app initialization while minimized
It's by default, please refer to StartupTask document If the user consents, the UWP app will then start on startup or user log in. Note that UWP startup apps will start minimized. when app minimized, the OnSuspending will be called (by design). if this behavior cause app initialization fail, please take care of OnSuspending event, and saving necessary application state.

Detect user selected option on Windows preventing restart C#

So i have a program that runs in background and by accident i found that if you prompt restart and get the screen that some app prevents it if you click cancel my app actually dies. Is there a way to make app wait more or to check what user selected on that screen.
What i meant is this:
After this screen when i go cancel my app is dead.

App launched due to push notification tap

Hello I am working on a windows phone 8.1 (RT) application and I am receiving push notifications on the app. What I want to do is, check if the user tapped on the push notification to launch the app. Because in my case suppose the push notification says "new story about Batman", now when the user taps on the push notification I need my app to navigate to the storyPage.xaml and update the view about the new story about Batman. I tried to search online but I couldn't find anything useful and I know it's possible because we all use whatsapp. when we tap on the notification about the message, that particular chat opens. I found This Link but I don't know where to put this code. How can I achieve this? I need help Thanks.
While sending push notification, you toast xml should have launch parameters.
When the user taps or clicks the notification, the associated app is automatically launched, and so its OnLaunched method is invoked. If we want to determine whether the app is activated by a toast notification click, we can use the Arguments property of the LaunchActivatedEventArgs object that is passed to this method.
Please have a look on this blog: https://marcominerva.wordpress.com/2013/03/25/how-to-pass-arguments-to-an-app-activated-by-a-toast-notification/

Show pending push notification count in Windows Phone

I am creating an WebView app i.e it contains only WebBrowser control which opens some enterprise mobile web app. I am using Urban Airship for push notifications.
Now I want to show the pending tile/toast notification count as badge on tile as well as on lock screen. How do I perform that? Is there any event which occurs when notification is pushed, if yes how can I use to maintain the count? Can I use background task? I am thinking to clear the badge when app is launched.
I am totally new in push notifications for Windows Phone. I searched a lot but didn't get expected results.
Get tile notifications count Windows phone
Count unreaded Number of missed call and message in windows phone
Here is a good sample of tile notification in msdn. You don't even need a background agent for this task, it will be done by the system. There is also a toast notification sample.

Toast is not shown while application is launching in windows phone

I am developing a Windows Phone 8 application, and I've implemented a background agent which does some work and also updates my application's Tile and shows a toast notification to the user.
It works, except when I am launching the application (more specifically when control is in the Application_Launching event) in which case the Toast notification is not shown, but the Tile still gets updated. Has anyone ran into this before?
A toast will not be displayed if the current foreground application is the caller of the Show method. Toast notification only display in the running background agent or some of the work are finish.

Categories

Resources