Location Sharing in Mobile App Chat

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Location Sharing in Mobile App Chat
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Location Sharing in Mobile Chat

A "Share location" button in chat looks simple until you encounter iOS 17 differentiating one-time location (requestLocation) from continuous monitoring (startUpdatingLocation), and Android 10+ requiring separate ACCESS_BACKGROUND_LOCATION permission for background updates. Plus, live location sharing (where buddy sees where you're driving in realtime) is a fundamentally different architecture from a single coordinate snapshot.

One-Time Location vs Live Tracking

For one-time "where am I now" — request coordinates once, form message with static map and send as attachment. Buddy sees map preview with marker.

Live tracking — separate message type in chat (e.g., type: "live_location") with lifespan. Google Maps Messenger and WhatsApp limit broadcast to 15-60 minutes. After time expires, backend auto-closes session, message becomes "static".

One-Time on iOS

import CoreLocation

class LocationManager: NSObject, CLLocationManagerDelegate {
    private let manager = CLLocationManager()
    var onLocation: ((CLLocation) -> Void)?

    func requestOnce() {
        manager.delegate = self
        manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
        manager.requestWhenInUseAuthorization()
        manager.requestLocation() // single request
    }

    func locationManager(_ manager: CLLocationManager,
                         didUpdateLocations locations: [CLLocation]) {
        guard let location = locations.last else { return }
        onLocation?(location)
    }
}

requestLocation() gives exactly one update and stops. Use kCLLocationAccuracyHundredMeters — chat doesn't need meter-level precision, saves battery.

Live Location: Architecture

Broadcasting current position requires three layers:

  1. Mobile client-sender periodically writes coordinates to server
  2. Backend stores latest coordinates and broadcasts updates to subscribers (WebSocket / SSE)
  3. Mobile client-receiver gets updates and moves marker on map

On Android background coordinate updates — through FusedLocationProviderClient with WorkManager or ForegroundService. WorkManager alone won't work: PeriodicWorkRequest has minimum 15-minute interval, useless for live location. Need ForegroundService with status bar notification — user must see app actively using GPS.

class LocationTrackingService : Service() {
    private lateinit var fusedLocationClient: FusedLocationProviderClient
    private val locationCallback = object : LocationCallback() {
        override fun onLocationResult(result: LocationResult) {
            result.lastLocation?.let { location ->
                sendLocationToServer(location.latitude, location.longitude)
            }
        }
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        startForeground(NOTIFICATION_ID, buildNotification())
        fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
        val request = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000L)
            .setMinUpdateIntervalMillis(3000L)
            .build()
        fusedLocationClient.requestLocationUpdates(request, locationCallback, mainLooper)
        return START_STICKY
    }
}

On iOS live broadcast works through startUpdatingLocation with allowsBackgroundLocationUpdates = true and UIBackgroundModes: location key in Info.plist. Without this key — crash in development, not on review.

Display on Recipient's Map

Recipient sees buddy's marker over their own location. Movement animation — mandatory, otherwise marker "jumps".

Message with live location contains session_id. Recipient subscribes to WebSocket channel of this session:

ws://api.example.com/location-sessions/{session_id}

Every N seconds server publishes {lat, lng, bearing, accuracy}. Bearing needed to rotate icon in direction of movement.

Static Map Preview

For one-time location in chat bubble, render static image through Google Static Maps API or MapKit Snapshot:

// iOS MapKit Snapshot
let options = MKMapSnapshotter.Options()
options.region = MKCoordinateRegion(
    center: coordinate,
    latitudinalMeters: 500,
    longitudinalMeters: 500
)
options.size = CGSize(width: 240, height: 160)

MKMapSnapshotter(options: options).start { snapshot, _ in
    guard let snapshot = snapshot else { return }
    let image = snapshot.image
    // display in chat cell
}

Snapshot renders async — doesn't block UI on fast scroll.

Timeframe

2–3 days for one-time location with static preview. Live broadcast with ForegroundService / background mode — 4–6 days. Cost calculated individually.