1

I was wondering if what I want is possible and if so if somebody could point me in the right direction. What I want is to SET a date for something to happen, and then when that time comes some piece of code gets executed...for example it sends a notification and when the app is opened and the notification is tapped another piece of code is ran...but that code could not run unless the date and time has come.

I have seen similar questions for other languages like javascript and they all get negative votes.

RubberDucky4444
  • 2,330
  • 5
  • 38
  • 70
  • 1
    you need a custom server which schedules task on your firebase db based on the time/date you set. – Shubhank Jun 08 '16 at 06:24
  • @Shubhank so if i dial it back...say when a user logs into the app...and he or she is tied to that event..and the date comparison shows its passed then it updates (deletes, etc) the "room" instead of firebase automatically doing it...would that be possible? – RubberDucky4444 Jun 08 '16 at 06:29
  • 1
    automatically won't happen till you make a custom server that does the part of running task automatically. There is no way to schedule task yourself in firebase so you would have to make a manager on your server that does the time check itself every 10 min or so.. it might be possible to spawn a new thread at the time you set too (not much sure of the backend possibility). Can't be done inside app for sure. – Shubhank Jun 08 '16 at 06:32
  • gotcha...i guess sincei don't know much about custom servers i will not be able to do what i want in any form...thank you both for your help and patience – RubberDucky4444 Jun 08 '16 at 06:35

1 Answers1

1

I think you should dive into how NSDate works. From what I understand, you want to get a future date and then compare it to the current date. You can create a future date like this:

How do you create a swift Date object

I think this explains best what you want to achieve:

NSDate Comparison using Swift

Community
  • 1
  • 1
Jer
  • 37
  • 6
  • The only thing Im concerned about @Jer is if...lets say I create something and expect 4 users to join in...but only 3 do but the time expires..i want firebase to automatically run some code – RubberDucky4444 Jun 08 '16 at 06:11