Timer in Windows 8 app in background - windows-8

I'm toying with Windows 8 SDK and I'd like to create an app that does something when a timer elapses. I've found out that when the app is suspended, the DispatcherTimer stops and resumes when the app comes back into the foreground. However, I'd like to schedule timer updates also in the background. What is the preferred solution to this problem (scheduling task for the future while the app is in background)?

You can use a Background task. Take a look to the example available at http://code.msdn.microsoft.com/windowsapps/Background-Task-Sample-9209ade9.

I found following article really helpful when working with BackgroundTask
31 Days of Windows 8 | Day #12: Background Tasks

Related

React Native - Execute code in background on specific battery percentage

I have a react native application where the user can choose any battery level from 15 to 100. When his battery reaches the chosen value, javascript code should be executed.
Is there a way to do this when the app is in the background? I am aware I can have long running tasks, which will be displayed as a notification to the user and I can have my code logic there.
Are there any alternatives that do not include long running tasks?
My solution for this problem to register a BroadcastReceiver in android, which will be executed every time when the battery percentage changes. It works in background and if the battery reaches a certain threshhold, a headless task can be executed which will run javascript code.

Using Expo React Native, is there any way to run a stopwatch / timer in the background?

Problem
I've created a simple stopwatch app using Expo for React Native. When I leave the app (click the home button on iPhone), and return to the app, the stopwatch starts back up from the time when I left. For example, if the stopwatch is at 3 seconds and I leave the app for 5 seconds, when I return it is still at 3 seconds rather than 8.
Question
Using Expo, is there any way to run the stopwatch in the background? If yes, how? If no, what is the best workaround?
Resources
I've found similar questions that are dated, but I'm looking for something recent. Some of the resources mentioned in the other answers are the following:
https://docs.expo.io/versions/v35.0.0/sdk/background-fetch/
https://github.com/ocetnik/react-native-background-timer
It sounds like your best bet is to note the start time and persist it, e.g. using Expo's AsyncStorage. Then you can just display the time elapsed since this stored start time.

iOS 7 remote notification background mode

I'm realy confused about this subject, my question is simple: when the application: didReceiveRemoteNotification: fetchCompletionHandler: will be called?
if the application is running and in foreground ? i test and the response is yes for iOS 7 and no in iOS 6 as described in the function comment.
if the application is in background and running ? response: same as 1.
if the application is in background but suspended by the system ?
most importent point: if the application is killed (not in the "multitask view")?
how i activate/handel the notification :
add the remote motif in xcode capabilities section (in info.plist).
ask to register :
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeNewsstandContentAvailability]
3 . implement the delegate method. (add inside completionHandler(UIBackgroundFetchResultNewData);)
when i send a notification (with the content-available key==1) :
if the app is in foreground/background and running the function is triggered and the code inside is performed (i download an image and save it in documents folder).
if the app is killed, the image is not downloaded.
second question : have you any easy why to debug remote notification background mode?
[edit] after tests, if the app is suspended (we add a loop to log date) it receive the notification and try to trigger code, but the app is stopped after 1 seconde, have we miss a parameter to encase duration ? (as i read the maximum is 30 secondes).
Sorry to answer my own question,
to be simple the remote notification is only handled when the application is in background(active/suspended).
[EDIT]: if you want to have a push notification that awake the app even if it is killed take a look at PushKit but this only possible if you have VOiP feature in your app.

WP8: Can this (PhoneApplicationService.RunningInBackground ) be used outside of location based app?

From this link below, it seems that your app can still get event when app is switched to background. But it seems it is used only for location based app. Can normal app do that? I had tried to declare ID_CAP_LOCATION but still Application_RunningInBackground not get called when switch to background.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.phoneapplicationservice.runninginbackground(v=vs.105).aspx
The app doesn't execute in background, unless it is continously tracking the location.
This section lists the conditions under which the operating system
will deactivate an app running in the background....
The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and
StatusChanged events of the Geolocator class or by calling the Stop()
method of the GeoCoordinateWatcher class.
Source: Running location-tracking apps in the background for Windows Phone 8
You will find complete info of how to run apps in background here:
How to run location-tracking apps in the background for Windows Phone 8

how to delay application quit time in iphone sdk?

I want to register my app for push notification when my application terminates so i think if i delay my app quitting time it could be possible.Does someone knows how to delay application quitting time? I think this method
[self performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait];
will do my job but i don't know how to use this method if someone knows please tell.I need to send some data to a server along with registering for Push Notification when my app quits.
I can't imagine why you would want to do this. If it were even possible it would be extremely annoying for a user to tap the home button and the app to take x amount of time to shut down. This time 'x' being dependent on the server connection creates even more user headache.
Apple have the home button exit apps immediately for a reason.
If you want to register the Push Notifications like you suggest, do it while the app is running. If your worrying that they won't be properly set if the user exits prematurely... don't.
As users, we all know there are sometimes consequences of exiting a program without giving it time to save your settings.
For push notification it is better to register when the app first starts and then send the push token to your server in the background. However, if you have a good reason why you need to do the registration just as the app terminates, I believe you can do this if you are using iOS 4. iOS 4 has a new feature called "task finishing" that allows an app to stay running for a few minutes after the user closes it so that it may finish up any tasks it was in the middle of (such as saving data).