0

As per my scenario i.e. needs to call api, then show local notification, again need to call api.

so each time 3 procedure needs to followed, even if application is active or in background.

I have tried to use NStimer for this but timer stops working when application is in background, and also I can't schedule local notification as it needs to call api before/after showing notification and also local notification content is dynamic every time.

I have also enabled background mode in xcode capabilities in that "Uses Bluetooth LE accessories".

Any other suggestion would be helpful, I just want api call before and after showing local notification

STEPS TO REPRODUCE

NSTimer should work even if application enters to background mode, after 1 hour api should be called, local notification should be displayed, again api should be called that notification is displayed.

so every 1 hour this 3 procedure needs to be followed, each time local notification content will be dynamic.

I just want timer to be running when application is in background.

Chirag Kothiya
  • 955
  • 5
  • 12
  • 28
  • It is not possible to nstimer to work in background but what you can do is you can get time when applicationdidenterbackvround and applicationdidbecome active or applicationwill enterforground and find the time interval between them in seconds – Devil Decoder Jun 25 '18 at 11:48
  • @RoboRewards Developers check this link https://stackoverflow.com/questions/31821339/how-to-send-a-localnotification-at-a-specific-time-everyday-even-if-that-time-h – Jigar Jun 25 '18 at 11:54
  • You should use push notifications. It is better to perform the api operations on a server where power and bandwidth aren't an issue and then send a push notification when required. – Paulw11 Jun 25 '18 at 12:02
  • @Paulw11 I'm using Beacon. how would server know that device is connected with beacon or not. If it is conntected then the local notification and api call should sent – RoboRewards Developers Jun 25 '18 at 12:35
  • You didn't say anything about using iBeacons in your question, however when you enter the beacon region your app can notify the server and when you exit the beacon region you can again notify the server – Paulw11 Jun 25 '18 at 12:58

0 Answers0