Foursquare Movement SDK for Flutter

A third-party Flutter plugin for the Foursquare Movement SDK, enabling passive location detection, geofencing, and venue matching in your Flutter apps.

Features

  • Passive location detection
  • Venue matching and place detection
  • Geofence monitoring
  • Debug tools for testing

Installation

Add to pubspec.yaml:

dependencies:
  foursquare_movement_sdk: ^0.0.1

Or use a git dependency.

Platform Setup

The Movement SDK must be configured in native code before your Flutter app starts.

iOS

  • Add location keys to Info.plist (Always/WhenInUse) and UIBackgroundModes with location.
  • Configure in AppDelegate.swift:
import MovementSdk
MovementSdkManager.shared.configure(
  withConsumerKey: "YOUR_CONSUMER_KEY",
  secret: "YOUR_CONSUMER_SECRET",
  oauthToken: nil,
  delegate: nil,
  completion: nil
)

Android

  • Add location permissions to AndroidManifest.xml including background location if needed.
  • Configure in Application:
MovementSdk.with(
  MovementSdk.Builder(this).consumer("YOUR_CONSUMER_KEY", "YOUR_CONSUMER_SECRET").enableDebugLogs()
)

Usage

import 'package:foursquare_movement_sdk/foursquare_movement_sdk.dart';

await MovementSdk.start();
final current = await MovementSdk.getCurrentLocation();
print(current.currentPlace.venue?.name);

Real-time Events

Listen for visit and geofence events via broadcast streams:

MovementSdk.onVisit.listen((visit) {
  print('Visited: ${visit.venue?.name}');
});

MovementSdk.onGeofenceEvents.listen((events) {
  for (final event in events) {
    print('Geofence ${event.eventType}: ${event.name}');
  }
});

Testing

Unit Tests

Run unit tests for the plugin's Dart API and data models:

flutter test

These tests verify that the Pigeon-generated API surface and data models are correctly constructed.

Example App Tests

The example app includes widget tests and integration tests:

cd example
flutter test                                    # Widget tests
flutter test integration_test                   # Integration tests

Important: Integration tests require:

  • Valid Foursquare Movement SDK consumer key and secret configured in the native code
  • Location permissions granted on the device/emulator
  • The SDK to be properly initialized

Without proper SDK configuration, integration tests will fail with authentication or SDK initialization errors.

Building the Example

To build the example app for Android:

cd example
flutter build apk --debug

For iOS (requires macOS with Xcode):

cd example
flutter build ios --no-codesign

Static Analysis

Run static analysis to verify code quality:

flutter analyze

Requirements

  • Foursquare Credentials: Obtain consumer key and secret from the Foursquare Developer Console
  • iOS: iOS 13.0+, Xcode 14+
  • Android: minSdk 24 (Android 7.0), compileSdk 36
  • Location Permissions: Both platforms require appropriate location permission declarations and runtime permission grants

Documentation

For more information about the Foursquare Movement SDK, see the official documentation.

License

MIT. See LICENSE.