Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to force the device's date to test local notifications?

I am creating a UILocalNotification with a particular date.

I want to test the reminders that I set for different days. I also want to see if the repetition feature works. Is it possible to force the current time to different date and time so I can see whether it works?

like image 227
Joe Avatar asked Jan 07 '23 08:01

Joe


2 Answers

Well one way that I used to do it is to actually change the time and date on my iPhone itself through the Settings app.

If you don't know where to do this, here's a wikihow article.

If you pass the time/date when the notification is supposed to go off, your iPhone will automatically make it go off.

like image 129
Liftoff Avatar answered Jan 16 '23 17:01

Liftoff


As David pointed out, you have to check by changing the date and time on your phone. But I would also like to point out something.

The default timeZone() of a notification is set according to your location. So even if you manually change the device date and time, the notification will not fire up. For it to work properly you need to set the timeZone() to systemTimeZone(). You can try this:

    notification.timeZone = NSTimeZone.systemTimeZone()

Hope this helps. :)

like image 31
bhakti123 Avatar answered Jan 16 '23 17:01

bhakti123