Location Tracking

Location Tracking

In many cases it’s important to log the location of a user and associate that location with other events. The mParticle SDK allows you to include detailed location information with all of your events.

It’s common that developer share the same code between a Unity app for iOS and a Unity app for Android. To best support this, the Unity SDK provides an abstraction layer to allow you to use the same Unity c-sharp code. The LocationRange enumeration will be translated to it’s closest meaning, depending on the run-time platform.

//On Android, GPS, Network, and Passive correlate 1-1		
//with the native Android location provider types,		
//which are themselves a proxy for accuracy.		
		
		
//On iOS, the values of this enumeration correlate to		
//the minimum accuracy in meters required of an acceptable location.		
		
public enum LocationRange {		
    GPS = 1,		
    Network = 500,		
    Passive = 3000		
};		
//On Android, minimum distance correlates to the minimum		
//distance required between individual location updates.		
		
//On iOS, minimumDistance is not used.		
MParticle.Instance.BeginLocationTracking (LocationRange.Network,		
                                          minimumTime,		
                                          minimumDistance);		
		
//Ends tracking location		
MParticle.Instance.EndLocationTracking ();