Create Geolocation plugin for phonegap iOS to run in background - ios

since watchposition doesn't run for more than 30 min in background, i have to create a geolocation plugin in order to register position every 5 minute on my webserver.
Ther problem is that i don't know quite nothing about objective-c. So anyone can help me or give me some parts of code with i can do something? thanks in advance

You don’t need to create a plugin for your phonegap app to receive location updates in the background. I’ve produced an iOS version of my phonegap-based navigator app and successfully got it receiving position updates while running in the background. I’ve tested it extensively in the “real-world” and it works reliably without any limit on the duration for receiving location updates.
Firstly, you need to be using XCode to develop your phonegap app - I’m not sure you can set the correct properties in your iOS app if you’re using Phonegap Build. You can set the “UIBackgroundModes” key with a value of “location”, which will cause iOS to trigger the JS callback function you have registered with watchPosition() each time a location update is received.
See this page for details about iOS project keys.
See this page for how to set the background modes key in XCode. The value you want to select is “App registers for location updates”.
Hope this helps!

Related

Can I do a background api call when the app is terminated/killed by the user in react native?

Can I do a background api call when the app is terminated/killed by the user in react native?
I tried with react-native-background-actions & react-native-background-timer.
Working fine in android but not in IOS when user terminate/kill the app
iOS have stricter policies about allowing background tasks to run when the app is killed, probably thats why you are facing this issue. Its not impossible to achieve what you are trying to, however its not very reliable, given that apple have full control of these tasks and when/if they are executed. You can try https://github.com/transistorsoft/react-native-background-fetch, its very well documented and might do the job for you.

Meteor + Cordova: getting user's location when app is terminated

I'm currently working on a location based Cordova + Meteor (iOS) mobile-app, where I need to keep an eye on the user's location, even when the app is terminated.
For this I have tried to implement the cordova-background-geolocation-lt plugin, but I'm having issues: https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/221
Because of this I am thinking of writing my own native (obj-c/swift) plugin (partly using code from this answer) that will get user's location and send it to the server.
My question is:
From this answer:
When iOS wants to return the location update to the app, it will help you to relaunch the app and return a key UIApplicationLaunchOptionsLocationKey to the app delegate method didFinishLaunchingWithOptions.
When app is killed/terminated/suspended - Is it possible to relaunch only part of the Cordova app - only native code that is responsible for background geolocation tracking and posting it to the server without fully relaunch the whole app - JS part & Meteor part?
There is an Apple article here about background tasks: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
Meteor generates the IOS code, but you can use XCode to modify the project and code somewhat, or I think you are correct in your approach to creating a plugin, because then you are in the native environment and can do these things.
I was able to succesfully use this plugin in my Meteor + Cordova project after resolving this issue: https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/221 . It turned out that this issue was due to the Meteor's local server suspension after the app enters background state. It is specific to the Meteor-Cordova projects

cordova getting Location Updates for iOS 7 and 8 when the App is Killed/Terminated/Suspended

I'm working on a cordova application which needs to get location updates and send them to a server even if the device is in sleep mode. I can track the location of a device if the app is on foreground and also background with my version now. But after 10-15 minutes the app gets killed by OS and I no longer get any location updates until the user launches my app again.
Well in my search of finding a solution to this problem I found this article:
http://mobileoop.com/getting-location-updates-for-ios-7-and-8-when-the-app-is-killedterminatedsuspended
It shows how to get location updates even if the app gets killed. The main problem is that I'm not really sure that this could work with a non-jailbreaked iOS and I've never wrote a cordova plugin myself before.
So is it possible to track location and send those through socket.io or http to a specific server?
Or at least to write those geolocation updates in files which I would send when my app launched?
If the answer of my first question is yes: How should the plugin look like?
#Kingalione,
you can keep the App from being killed. There was a documentation error in Apple's documentation. Here is my blog post on this:
Slight Documentation Error causes Background Operations Issuehttp://codesnippets.altervista.org/blog/2015/BLOG.2015-07-02.jssnippets.html
To apply this fix, you'll need to add to your .plist file. Unfortunately, I do not know how to do this for the Cordova CLI. Here is the section that you need for UIBackgroundModes

Worklight - Geo location not working in background in iOS

I have implemented the Location services in android and it can continually get the device's position even when the application is in the background. However, when I tried it running in an iOS Simulator and iOS device, the device stops retrieving its location when I place the application in the background. I don't think this should be the behavior. Is there other settings needed to be configured for iOS? thank you very much in advance.
Per the discussion in the comments:
Make sure to also set the Geolocation permissions in the *-info.plist file in Xcode per the instructions in the training module (slides 21-22) and/or the user documentation.

How to update Geofencing list of points in iOS into Background

I would create an iOS application with geofencing.
Can I send a new list of geofencing points to this app through Apple Server in Background or must I launch the app to update its list of points ?
More easily, can I from an external server change the geofence point without launching the app ?
Thanks you very much.
Best regards
Assuming your app doesn't use any of the available background modes, you can't change them remotely. The push notifications are received and shown by the OS, and only opening them will trigger your app to load and execute your code.

Resources