I am currently segmenting users by a location filter. However the location is only updated if the mobile app is in foreground. Is there a way to mimic the user's last activity / currently location every hour even if the app is in the background? I am currently using React Native.
You can update the player / user record with the last location through the REST API by sending lat and long.
https://documentation.onesignal.com/reference#edit-device
You will need to use a plugin or your own native code to get the location of the device in the background.
Related
I am working on a project, and we need to record analytics concerning how long a user spends on each page. We have looked into Firebase analytics, but since we are using Expo, it is not fulfilling our requirements. How would I set a timer on each page so that I can record the time spent on each page? We have navigation set up like this:
navigation.navigate('RelatedCauses', {
relatedCauses: causesDic
})
Also, how would I detect the user closing the app, so that I can record the end of a session?
I have an Expo (React Native) app in the Apple App Store.
When it is opened and starts — I fetch a bunch of data.
If I leave the app (but don’t technically “close” the app from the app switcher), then every time I open the app again, it opens on the same screen (the screen / components persist)
This happens even if it’s the next day
Ideally, after some amount of time (hours?) I would like the app to fetch data, but since the previous screen persists and the component is already mounted, I don’t know how to fetch new data
Obviously if you manually close the app (go to app switcher and swipe up to close app) upon next open it will mount the components and fetch data...
Is there a setting for the app to “close” on its own after a certain amount of time?
Thanks in advance!
You can use the following tools:
To detect when the app changes from active to backgrounded: https://docs.expo.io/versions/latest/react-native/appstate/
To fetch data in the background: https://docs.expo.io/versions/latest/sdk/background-fetch/
I have a requirement to save user's geolocation when react-native app is running in background. I know react-native-background-geolocation is available for this but I don't want to use any third party tool for this. Is there a way I can fetch users current location even if the app is running in the background?
With the last Expo SDK 32 you should be able to to it.
We’re excited to announce that this release includes initial support for background location, a highly requested feature from many Expo users. You can now define simple JavaScript tasks in your app and register them to receive location updates in the background. Additionally, you can set up geofencing tasks that are triggered when the device enters or leaves specific geographic regions
In Titanium there is the following property:
Titanium.Geolocation.lastGeolocation
As explained in this doc: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation
It is described as follows:
JSON representation of the last geolocation received.
LastEvent is the JSON version of the last geolocation sent by the OS.
This does not trigger a geolocation attempt, nor wait for such. If no
geolocation has happened, this value may be null or undefined.
My question is when it says "lastGeolocation", does it mean the last geolocation recieved my the device ever (e.g. The app could have got a location from another app such as Google Maps), or just the last geolocation received by the app?
I believe it should be the device's last location irrespective to which app requested for it.
It is easily checkable with following steps:
Get a fresh current location from the Titanium app & check the value of lastLocation.
Do a location request from another place with different app like Google Maps.
Then check it again in Titanium app.
How i can track user location using CoreLocation and MapKit? I place a point on the map. When the application is minimized to check whether the user has not reached the destination. If you reached to withdraw the notification.
Allow your application to run in background
In background, start your get geolocation thread active to get current location (on timely basis, after each 10 secs)
If the results gets approx. equal value (for ex.: 2 km. radius) to your location, then throw a local notification from that app.
To do all this, you will surely find documentation over web, topics are:
Allow your app to run in background
Fetch user's current location (Start this thread in background delegate method)
Match location
Fire local notification
These are the base flow points, hope this will help you for initial start up.