Implement logic for multiple local notifications daily at different times in iOS

In fact, I am developing an application that triggers local notifications when sunrise and sunset (which is different daily, so you can not use an alarm clock). In addition, I need this feature offline.

I already tried:

  • Register notifications for the whole year immediately, but this does not work due to limitations of notification restrictions.
  • Register the next notification of the trigger event of the current notification, but this logic fails when the notification does not start, when the device is turned off.

Any help would be greatly appreciated. :)

+5
source share
1 answer

See this fooobar.com/questions/1271182 / ... for an API that you can use to receive callbacks at different times regarding sunrise / sunset. This answer explains how to use the API.

This question is slightly different from the other, so I am not duplicating it. The fact that this is related to this issue is that you do not need to pre-calculate the sunrise / set for long periods of time and register a bunch of alarms. In addition to the inelegant solution, the precommute will not work on mobile devices, because the sunrise / installation depends on the location of the device, and you cannot know where the device is for a long time in the future.

With the proposed Awareness API , in particular TimeFence.aroundTimeInstant () , you will automatically receive a callback at a certain offset from sunrise / install, and you can unregister from the API at any time to stop receiving them.

0
source

Source: https://habr.com/ru/post/1271181/


All Articles