ios schedule local notification after a delay with repeats - ios

I need some help with scheduling local notification after a some delay that is repeating every 5 minutes. I'm using UNTimeIntervalNotificationTrigger (https://developer.apple.com/documentation/usernotifications/untimeintervalnotificationtrigger) to achieve repeats with every 5 minutes. But I didn't manage to find the way to delay this.
I can't use dispatchAsyncAfter because app can enter into background.
What I want to achieve is following: When user accept some event (tap on button). I want to have a reminder for him to finish the action. So i have scheduled one notification after 30 seconds, then next after 1 min and then each notification after every 5 minutes until he finish the action.
So basically I need to schedule one time interval local notification that starts appearing after exact 6,5 minutes when user tap on button.
Any ideas?

Related

How to create an alarm timer in react native

I'm trying to replicate the native iOS timer with a light theme.
I've tried achieving the repeating sound functionality in the following ways and none worked while the app is in the background:
(I'm using react-native-background-timer and notifee)
Recursively fire a "play sound" function when the timer is up - doesn't work on background, the sound is played only when I open the app
Recursively schedule local notifications for when timer is up - only the first one fires, i.e. the notification when the timer is up, but after that nothing
If going with the notification route, I'd like to do something like:
notifee.displayNotification({ loopSound: true, ongoing: true })
Currently my last resort is scheduling a bunch of notifications ahead of time while the app is in the foreground, about 6 seconds apart each.
This is hacky and also if the user looks at the lock screen or notification center they'd see all these notifications which are one and the same.
I tried doing the same with passing the notification id, i.e. to update the same notification instead of creating a new one each time, but then the notification is only displayed once, at the latest scheduling.
Any ideas how to go about it?

Text Countdown Timer Inside Push Notification

I would like to have a timer inside my iOS push notification. Like when it comes down from the top of the screen, I want it to say You have \(time - 1) seconds to respond! How can I code that?
Not saying I would do this, but you could check out the "apns-collapse-id" key in the APNs header. It allows you to send multiple push notifications, and each one will replace the last. You could send one push "You have 120 seconds to respond!" and then 30 seconds later, using the same collapse id, send another "You have 90 seconds to respond". The previous push will be replaced with this one.

iOS 7-8 Background Timer

I've searched a lot and didn't find anything that helps. Basically I need to develop an app, that vibrates every X minutes in time interval (provided by user, from 15 to 180 min), also it must be executed in background. Can this be achieved?
UPD:
It should play sound, vibrate or both of these. For example: user selects 40 mins, and sound should be played every 3 minutes. It must play/vibrate in background and foreground, after time passes, notifications should simply stop.

run ios app in background

I'm new to iOS programming, I've managed to create a countdown timer that counts down to 0 and when the timer reaches 0 an UIAlertView pops up to say that the timer is done.
Although my problem is when I minimize the app or if the screen goes to sleep my countdown timers stops and my alert won't show up until I start the app again and let it count down to 0.
So my question is basically, how do I let the app run in the background, or at least let it count down in the background?
Thanks in advance!
The easiest way will be to create a "local notification". When your app enters the background, cancel your timer, but schedule a local notification that will fire at the fireDate corresponding to when your timer hits "0". If the local notification fires while your app is in the background, the user will be presented with an appropriate alert and will have a chance to launch your app.
See the Apple Local and Push Notification Programming Guide for instructions on how to schedule and then handle a local notification.

UILocalNotification - Need to vibrate for a longer duration during the alert / notification

Overview
In my iOS project, I am using UILocalNotification,
when a notification is fired, a custom sound is played.
the custom sound plays for about 20 seconds,
the phone vibrates only once at the start
What I want to do:
Presently the phone vibrates only once at the start. I want it to vibrate repeatedly for 20 seconds just like in Apple's alarm / Timer app before the user pressed on the action button ?
Question
During the alert is it possible to make the phone to vibrate for the 20 seconds before the user can attends to the notification or clicks on the action button ?
Problem
Since my app doesn't have any control till the user presses on the action button I am not sure how I can make it vibrate
The app might be closed when the notification is pops
Is there a way to do this ?
Schedule a timer that invokes the vibration function several times with some delay between calls. Don't forget to add an option to disable the vibration, cause you might get your app rejected from the app store because of this.

Resources