-1

Hi i have to create a service in IOS OS that sends data like current location details,battery level,and other info every 15 min to the server via post api ,I understand it will not work once app is removed from app stack forcefully.But can i do something so that service will run ,background until app is killed forcefully.I know we can do only some work in background modes.Can i do someway around so that my app service always run in background

  • 1
    There is no way to schedule execution on iOS with a specific time interval. You could use location updates, but this can drain the battery and you won't get any updates while the user isn't moving. – Paulw11 Jun 23 '16 at 10:02
  • thanks for comment @Paulw11 i understand it will drain battery and background location updates will give location every second,but i want to get location updates on every 15 mins and send it to my server,Can we do anythings as services in android – Raghvendra srivastava Jun 23 '16 at 10:05
  • No, iOS doesn't support long running "services". There are only the specific background modes. – Paulw11 Jun 23 '16 at 10:09
  • Ya i know can we perform something like significant location updates to ios os to give location update either if there is changes 1000 m or after sometime I knew significant location updates are not accurate.Is there any work around – Raghvendra srivastava Jun 23 '16 at 10:12
  • Significant location update will give you an update when the user moves by about 500-1000m but there is no time factor. If the user doesn't move then there is no update. – Paulw11 Jun 23 '16 at 10:17

2 Answers2

0

Use NSTimer and call that method which contains API call, Hope this solves your problem.

0

I am sure, your problem is might be solve by Apple push Kit. For this you have to need a back-end service. Generally ApplePushKit used for the VOIP(Internet calling and video call).

You have need to do following thing.

1) You have to Fire Notification every 15 Min(Pushkit notification not shown by user because it is silent never show to user).

2) You have receive controll in PKPushRegistry in method

3) You have received controll for the executed code for 30-40 second

4) Call Your API during the this time.

Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65