Implement a logic for multiple local notifications daily on different time in iOS
Asked Answered
B

1

6

Actually, I'm developing an App that triggers local notifications on sunrise and sunset time (which differs daily, so can not use alarm). Additionally I need this functionality offline.

I've already tried:

  • Register whole years notifications at once but it does not work because of notifications limit restrictions
  • Register next notification on trigger event of current notification but this logic fails when a notification does not trigger when device is switched off.

Any help would be appreciated. :)

Breunig answered 24/8, 2017 at 8:49 Comment(3)
Dear I have same problem have found any solution plz?Franctireur
No.. Still not found any solution.. If you find any please post it here.Breunig
ok dear sure will let u know bhaiFranctireur
M
0

Please refer to this stackoverflow post about an API you can use to receive callbacks at times relative to sunrise/sunset. That answer explains how to use the API as well.

This question differs slightly from that other one, therefore I'm not marking duplicate. The thing to add that is specific to this question is that you will not need to pre-compute the sunrise/set for long periods and register a bunch of alarms. Aside of being inelegant the precompute solution will not work on mobile because sunrise/set depends on device-location, and you cannot know where the device is located for long periods in future.

With the suggested Awareness API, specifically TimeFence.aroundTimeInstant() you will automatically get a callback at some specified offset from sunrise/set and you can unregister from the API at any time to stop receiving them.

Manhood answered 4/9, 2017 at 19:40 Comment(3)
Thanks for your answer, I've already found the solution for android using background services. This API works well but it's not available in iOS. Any Alternate solution for iOS?Breunig
Starting a background service for your app will not work your your app anymore due to background-restrictions from Android Oreo onwards. Perhaps using this or other API will save you time to migrate later on.Manhood
Ok, I'll use this API for android, but this is not available for iOS. What should i do for iOS ?Breunig

© 2022 - 2024 — McMap. All rights reserved.