Can we run some task on specific time in background if my application is running or on dormant state. Is this possible in windows phone 7.5 Mango. If Its not possible then any work around with the help of push notifications.
If you are not the currently active application in Windows Phone your application is being tombstoned, which means that some of your state is saved and your application is halted (e.g. there is no code running for your application anymore).
Therefor you can not create code that allows your application to do anything at a specific time, without using push notification.
Even with push notification your options are very limited. It realy depends on what you want to happen when a notification arives.
Related
I have Win32 desktop bridge application that uses background task to receive push notifications from WNS. I use UWP background task APIs over C++-WinRT
I'd like to be able to receive push notifications even when OS is in sleep so that it wakes up and the app handles push notification. By default OS does not wake up. It did only after manually changing settings value in System->Battery->See which apps are affecting your battery life->Click my app ->Uncheck Let Windows decide option (by default it is always checked) and check Allow the app to run background taks. Now I'd like to do this is manual work on code for better user experience.
RequestAccessKindAsync API allows to let user to change above setting value by showing popup notification to the user and I could do it without any problem in UWP C# sample app. But same code does not show pop notification from my desktop bridge over C++-WinRT. It simply returns false value for below code
auto result = co_await BackgroundExecutionManager::RequestAccessKindAsync(BackgroundAccessRequestKind::AlwaysAllowed,
L"App needs to use background to catch push notifications while device is in sleep");
Can anyone confirm that RequestAccessKindAsync API works from desktop bridge? If not then how I can make sure OS and the app will always be able to wake up from sleep when it receives push notification?
UPD: Raised request to enable this API from desktop brige here
This is a missing feature. When we designed this API a couple of releases ago we didn't consider desktop bridge apps would be calling it - but clearly there is a use case for supporting this. I have notified the team about this gap, but I'd also encourage you to log a feature request here: https://wpdev.uservoice.com/
Two possible workarounds:
(1) you could add a dummy/empty UWP foreground app to your desktop bridge app. You can then launch this on startup and request the background access from there. This will be a bit ugly, but you could make it look like a splash screen :-)
(2) you can instruct the user to go into the Settings app to set your app to always allowed. You can help them do that with a deep link to the battery save settings, but they will still need to manually flip the switch.
We're writing a cross-platform C# "Xamarin" application; right now we're just targeting the iPad. The application has two features relevant to this question:
The app requires that the user authenticate to the app (in addition to logging onto the iPad)
The app connects to a remote device over Bluetooth
So the question becomes, what happens when the user switches to another app, which results in our app's OnSleep() being called. In OnSleep() we could immediately disconnect Bluetooth and log out the user, but that seems like poor usability, especially if they are just quickly checking some alarm that triggered or an instant message that came in.
For the sake of usability, we're thinking to have a 1-minute timeout; if the user does in fact pop out and quickly pop back into the app, we'd like things to simply continue on without any loss of communication or re-authentication.
If, in OnSleep(), I set up a timer using Xamarin.Forms.Device.StartTimer(), that timer does not fire while the app is "asleep".
What does it take to have a small background task/thread/process execute, even while the app is asleep? Something that simply waits 1 minute, and then shuts down the Bluetooth communication and sets a flag indicating re-authentication is needed?
I have written a C# application that monitors a device attached to an ARM tablet running Windows 8. The application needs to detect when the tablet is resuming from sleep, so that it can send a command to the attached device.
I have tried monitoring the Microsoft.Win32.SystemEvents.PowerModeChanged event, as per this question.
I have tried watching for WM_POWERBROADCAST messages, as per this question.
In both cases the application works fine on my Windows 7 desktop development PC. However, neither approach works when I run the application on my Windows 8 ARM tablet.
Do I need to watch for a different message in this case? Is there something else I could try to work around this problem?
UPDATE: I have since found that when I plug or unplug mains power I do actually get a WM_POWERBROADCAST message (power status change). I also get a SystemEvents.PowerModeChanged event. However I am still not receiving any suspend or resume power messages when going through a suspend/resume cycle.
UPDATE #2: I have since found a workaround for my particular situation that does not rely on power messages. But thanks to those who took the time to answer/comment.
I am new to Windows phone 7 Push Notifications. I am able to send and receieve tile, toast notifications in my phone. However, my problem is, I want to save all these notifications to a local database in windows phone7.
When the application is running and if a toast message arrives, I can capture that event and we can save the data to local db, its fine.
But if the application is not running, and if I get a toast message, I need to save this message to the local database. I am unable to find a way for this problem. Please help me.
The bad news is that you can't do this at the moment (not in 7.0 or 7.5 Mango)
You can run background tasks on a WP7 device running Mango (7.5) while your app isn't running as detailed here: Windows Phone 7.5 Periodic Tasks
But there are limitations: The task will only fire once every 15 minutes or so, it won't be able to monitor for toasts while the app is off.
If you control the server that is sending the Toast messages then the best bet is for your periodic task to connect to the server every 15 mins and, if there are new toast messages, for it to collect them and then store them in the local DB.
I want to make a application that runs with no form interaction with user and only specific person can run a form and change config setting. The application is desktop reminder which runs every 4 months and shows up a notification.
I don't have any idea how to start it. Please guide me with some good suggestions.
If you have an application that needs to notify the user once every 4 months, its a bit overhead to have it running all the time.
Use the Task Scheduler in Windows, to schedule this command to run (once per day, or every week) check if the condition is met. If not silently exit.
You can effectively create a windows Service and then configure it to allow it interact with the desktop through the Services administration console.
However, for security reasons in W2008 Server (and I assume that more or less it will be the same with W7 or even Vista, you'll have to try it) this behaves differently, and services that interact with the desktop are not allowed. Actually, I remember that when I created and showed a Window I got a notification and when clicking on it the desktop switched to another one with my window. Still, no issue with XP, I've done it.