Keep the code Running In background in Ios - iphone

I want to run code in background for an infinite time and not for only 10 mins. I am not using Music or GPS or Viop. I want to show continuous local notification with some time interval. I have achieved the work with constraint of 10 mins. Please help.

What #phooze said was right.To show continuous local notification with some time interval use repeatInterval property.

Related

Flutter - Timer pauses unintentionally

I have implemented a Timer as detailed in the article below, so that the timer will keep running when i change tabs.
How to implement persistent stopwatch in Flutter?
I have an issue where the Timer "loses" or pauses time, only when not plugged into my computer. When i plug it into my computer, no issues, the emulator runs fine too. I test the flutter timer against a timer on my computer or phone, and after 5mins, they match. But when my phone (Galaxy S9) isn't plugged in, after 5mins of real time, the flutter timer might only be up to 2mins, when i go back into the app the timer is running but the timer wont be what it should be. It doesn't crash or reset, its counting when i get back into the app. I'm finding it hard to debug as when I plug the phone into my computer it seems to work fine! Any ideas?
I had issues with this as well. Things working correctly when running on the Simulator is fools gold. The Timer won't run in the background like you want it to unless you do specific work to keep it running. Here is the official page from Flutter on doing work in the background: https://flutter.dev/docs/development/packages-and-plugins/background-processes
I'll suggest implementing didChangeAppLifecycleState method of the WidgetsBindingObserver and detect when the app goes to the background and when it's back in the foreground. At the point where the app goes into the background, you save the current time e.g (onPauseTime) (you can use SharedPreferences here) and the Duration left on the timer (timerDurationLeft).
When the app is back in the foreground you check if the timer was running before the app entered the background state, if it was, you then check the current time e.g (onResumeTime) and calculate the time difference in seconds (onResumeTime - onPauseTime), using the time difference and the timerDurationLeft you can calculate how much time the timer has left to run and you start/resume the timer from that point or end/set the timer to 0:00 if time has already passed.
P:S Using a background service would be the way to go if you intend to perform some actions in the middle, like set notifications at some point where the timer is almost complete.

Keeping Apple Watch Awake for more than 70 seconds (watchOS 3)

Is there any way to keep an Apple Watch awake for more than 70 seconds? I understand the purpose of turning off the face to save battery life but I'm trying to sample motion data continuously for about 3 minutes and the sampling is interrupted as soon as the face turns off. I've set the watch to stay awake for 70 seconds every time I tap it, but is there any way to prevent it from turning off for > 3 minutes? I found this post from Feb. of 2016 but haven't found any updates confirming or denying the possibility of preventing the watch face from sleeping in watchOS 3.
If you're looking at sampling motion data like the accelerometer or gyroscope, you can create a HKWorkout Session that will keep your app running in the background. While your Watch face will still eventually turn off without tapping, you will still continue to be able to keep sampling your motion data. Note that only one HKWorkout Session can be run at a time. Hope this helps!

Alarm repeat in particular time interval

I know this question ask several time. Even i am trying this below code:
http://iphonesdkdev.blogspot.in/2010/04/local-push-notification-sample-code-os.html
Still I am not able to play alarm at particular time interval.
I have date-time picker. User select time from that date-time picker, which contain time from 1 min to 23 hours.
In my app alarm works but only one time. I need to play that alarm till user does not stop that timer switch from on to off.
Please Help me.
Any idea and suggestion is Appreciated!!!!
You can set RepeatInterval for your localNotification
[localNotification setRepeatInterval:NSMinuteCalendarUnit];
you can set its repeat interval according to you, it would be minute, hours, day,month, year.

What to happend when I registerLocalNotification to a past time?

If I register a NSLocalNotification to a past time,wheather it will destory automaticly,or it take one schedule count in the system and never destory.
As though,we know the loacalNotification is limit to the 64 counts,when the notification register to the past time got to the 64 counts.The other lotification Whether happend or not
If you create a notification in the past time .. it will play right then.. and your app delegate's didRecieveNotification method is called.

Is it possible to run a task periodically in Background - iOS 4

I want to poll the location from GPS in the background. So we used a NSTimer and performed periodic checks in the timer tick. In other words, can we schedule NSTimer while the app is in Background?
Thanks in advance
You can't periodically execute arbitrary code, but you can get pinged on significant location changes via startMonitoringSignificantLocationChanges in CLLocationManager.