What to happend when I registerLocalNotification to a past time? - iphone

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.

Related

Persistent stopwatch that can be paused/unpaused in flutter

My flutter app allows users to time how long they have been working for. I'm using the package stop_watch_timer.
Everything works fine except when the app gets killed in the background, because then I lose the timer value and it goes back to 0. As users are likely to start the timer then put their phone away and work for a while, the app getting killed is a very likely scenario and I need to make sure that this never happens. Another feature that I need in the app is for users to be able to pause and unpause the timer whenever they want.
Here are the solutions I have come up with so far and their problems:
Solution 1: Store the start DateTime on the phone using shared_preferences and calculate the current timer value when app is reopened by simply calculating the duration between start time and DateTime.now(). But then I realised that this does not work if the user had paused and unpaused the timer at some point.
Solution 2: Store the current timer value as a RestorableInt. This works if the timer is on pause when the app gets killed, but does not work if the timer is meant to be running when the app dies.
Any suggestions or ideas??
You should store something like this:
[
{"start":1664027960},
{"pause":1664027975},
{"unpause":1664027979},
{"pause":1664028061},
{"unpause":1664028065},
]
Everytime a user hits the pause button you add the time to the list and store it in the shared_prefs or in a json file. Same for unpausing.
You can then calculate the total ellapsed time.

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.

Is it possible to know the last call duration in iPhone?

Can I take the last call duration in iPhone by code? Is it possible?
The only thing I can think of is if the user called from your app, and automatically gets back to your app at the end of the call.
Then you can take a time stamp when the call started, before your app was terminated, and when your app goes back in :
-(void)applicationDidBecomeActive:(UIApplication *)application;
you can measure the time passed with the saved time stamp.

iPhone - NSTimer - Peculiar task needed

I know how to set a timer and when timer expires, it fires and a action is caught.
What I'm expecting is that after 30 seconds of every one hour of real time that that "xx:00:30" I have to check my server for updates.
I know how to communicate with server. But how can I create such a timer that fires every "xx:00:30".
I don't want to run the timer if the app is in background.
Any ideas on how to do this?
As mentioned by Marcus in his last message,
NSTimer's initWithFireDate:interval:target:selector:userInfo:repeats: or setFireDate:
works.

Keep the code Running In background in Ios

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.