How to send local usernotifications based on user input [duplicate] - ios

I am creating my first app that lets the user set alerts for themselves and then the app would send the user a local notification on the set time. The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week (for example every Mondays and Tuesdays only). All the tutorials/questions that I have come across so far (like this one) have only been about scheduling the notification everyday/everyweek. The desired result that I'm trying to achieve is sort of like the iPhone's built in alarm system, where you can set an alarm to fire only on certain days of the week.
If I can't just set the notification.repeatInterval field, is there a way I can do what I'm trying to do? Could I possibly execute a little code at midnight that schedules the correct notifications for that day? If so, how could I do that?
Thanks in advance!

The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week
In iOS 10, a UNCalendarNotificationTrigger is formed using DateComponents. This means you can specify as much or as little of the date-time in question as you wish. Thus, if you specify a specific weekday and a time (hour and minutes), and nothing else, you'll repeat at that time on that day of the week.
If you also need to repeat on a different day of the week, just make another notification.

Related

Repeating an event like in iphone reminder app

In iPhone reminder app you can set a calendar event to repeat, say, every three days after a specified date, until reaching another specified date. I am starting to create an app that should have a feature like that. My first attempt was to use local notifications, but I have not seen a way to program a trigger using date components to do that. Am I overlooking something about local notifications or date components, or are there other ways to do that?
Have you looked at UNTimeIntervalNotificationTrigger And UNCalendarNotificationTrigger?
You probably have to combine the two. Use UNCalendarNotificationTrigger for the initial event at a certain date and then UNTimeIntervalNotificationTrigger for repeating the event.

iOS: Limit local notifications to a certain time frame?

I am working on an app that uses local notifications, which are repeating in an interval chosen by the user (between 5 and 60 minutes).
I would like to enable users to also choose a certain time frame so that the app will fire notifications only during this time frame. I was thinking about using NSDate and some kind of conditional statement where the notification only fires if the current time is in the time frame which was chosen by the user.
Do you think that will work or am I overseeing something?
You can use UNCalendarNotificationTrigger for this.
Triggers a notification at the specified date and time.
See
official documentation.
Calendar triggers can also be repeating, so it should serve your purpose.

How to repeat local notifications on specific days of the week (iOS Swift 3)

I am creating my first app that lets the user set alerts for themselves and then the app would send the user a local notification on the set time. The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week (for example every Mondays and Tuesdays only). All the tutorials/questions that I have come across so far (like this one) have only been about scheduling the notification everyday/everyweek. The desired result that I'm trying to achieve is sort of like the iPhone's built in alarm system, where you can set an alarm to fire only on certain days of the week.
If I can't just set the notification.repeatInterval field, is there a way I can do what I'm trying to do? Could I possibly execute a little code at midnight that schedules the correct notifications for that day? If so, how could I do that?
Thanks in advance!
The thing that I'm having trouble with now is being able to fire the local notification on specific days of the week
In iOS 10, a UNCalendarNotificationTrigger is formed using DateComponents. This means you can specify as much or as little of the date-time in question as you wish. Thus, if you specify a specific weekday and a time (hour and minutes), and nothing else, you'll repeat at that time on that day of the week.
If you also need to repeat on a different day of the week, just make another notification.

Build a app to remind 6 times a day in different time a whole year?

I am a beginner and would like to make an app for iOS. I do not know where to start but I am not sure whether you can make an app that remembers you every day for a year at different times (I have time to write them in) .. ? Can you make something which can run in the background as the program 'Reminder'?
I will also have it's different in another selected city ..
Thanks
You can use local notification for that.
See this.
You can set time difference as per your requirement.
And even if your app is not running, or is not in background. It will work.
Like this,
local.fireDate = [calendar dateFromComponents:dateComps];
See this link or this , you will get the hint.
you cant run a program in the background all the time in IOS,
you can do 2 things:
you can add reminders to the calendar, so your app wont need to run all the time, only once to add it.
you can use push notifications and just send push to the users every time you want it, so all calculations will be on some php or java or any other server you want.

how to trigger a download on specific date

In my iPhone application I want to trigger a download every monday of a week, every 10th working day of a month, every 3rd day of a month etc. I did some R & D and found that NSDate, NSDateComponents & NSCalendar classes needs to be used for this scenario. Can somebody help in the same as I am new to date & time usage.
Also by the time when trigger comes if app is not in running state or mobile is switched off.. How to handle these scenarios.
If you device is switched off / out of order / app is not running, you can not do any thing.
Apple would not allow you to launch your automatically, so the question of downloading and saving is bit far.
What you can do is, whenever your app is launched you can read from plist or userdefaults about the time ( 3rd day of month ) and compare to the last saved date, if it is one month away then it is the time to download and show a popup to do so.
Only legal way to do this is to schedule NSLocalNotification to desired date. When notification is fired up and user taps it, app would be started, and there you should start with download.
The documentation for Local Notifications: Local Notifications
You can read this: iOS timed background processing
Can go through this tutorial as well.
I have reading up as well. Something new for me as well. Best is NSLocalNotifications. Have a look at this: Reminder App

Resources