radar_flutter_plugin

Radar is location data infrastructure. You can use Radar SDKs and APIs to add location context to your apps with just a few lines of code.

Documentation

See the Radar overview documentation here.

Support

This is a community developed plugin.

Flutter support:

  • x iOS
  • x Android

Features

  • user ID and metadata setting
  • Implementation of TrackOnce (get updated user state information at a desired point in the app lifecycle)
  • Support for different background tracking presets and customization.

Planned features

  • Event Listeners
  • Additional Radar APIs (search,geocoding,context,distance)
  • Support for trip tracking

Setup

Change the minSdkVersion for Android

radar_flutter_plugin is compatible only from version 19 of Android SDK so you should change this in android/app/build.gradle:

Android {
  defaultConfig {
     minSdkVersion: 19

Add permissions for Location

We need to add the permission to access location:

Android

In the android/app/src/main/AndroidManifest.xml let’s add:

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 <application

Add receiver and foreground service

        <receiver
            android:name=".MyRadarReceiver"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                <action android:name="io.radar.sdk.RECEIVED" />
            </intent-filter>
        </receiver>

IOS

In the ios/Runner/Info.plist let’s add:

	<dict>  
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Your iOS 11 and higher background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Your iOS 10 and lower background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Your foreground location usage description goes here. e.g., "This app uses your location in the foreground to recommend places nearby."</string>
    <key>UIBackgroundModes</key>
    <array>
      <string>fetch</string>
      <string>location</string>
    </array>

For location permissions on iOS see more at: https://developer.apple.com/documentation/corelocation/requesting_authorization_for_location_services

Usage

To use this plugin, add radar_flutter_plugin as a dependency in your pubspec.yaml file. For example:

dependencies:
  radar_flutter_plugin: ^1.0.0

Libraries

radar_flutter_plugin