<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="cordova-background-geolocation-lt"
    version="5.6.1">

    <name>BackgroundGeolocation</name>
    <description>The most sophisticated, battery-efficient background-geolocation and geofencing plugin for Cordova</description>
    <license>MIT</license>
    <keywords>cordova, phonegap, background geolocation, background, location, tracking, geofence, geofencing</keywords>

    <engines>
        <engine name="cordova" version=">=7.1.0"/>
        <engine name="cordova-android" version=">=7.0.0"/>
        <engine name="cordova-ios" version=">=4.5.0"/>
    </engines>

    <js-module src="www/BackgroundGeolocation.js" name="BackgroundGeolocation">
        <clobbers target="window.BackgroundGeolocation" />
    </js-module>
    <js-module src="www/API.js" name="API"></js-module>
    <js-module src="www/DeviceSettings.js" name="DeviceSettings"></js-module>
    <js-module src="www/Logger.js" name="Logger"></js-module>
    <js-module src="www/TransistorAuthorizationToken.js" name="TransistorAuthorizationToken"></js-module>
    <js-module src="www/Enums.js" name="Enums"></js-module>

    <!-- (WO-195) package="swift": cordova-ios 8 and later builds the plugin from Package.swift and gets
         TSLocationManager (and TSBackgroundFetch) from Swift Package Manager. Older cordova-ios ignores the
         attribute and uses the <source-file>/<header-file> and the <pod> below. -->
    <platform name="ios" package="swift">
        <preference name="BACKGROUND_MODE_LOCATION" default="&lt;string&gt;location&lt;/string&gt;" />

        <!-- required background modes:  App registers for location updates -->
        <config-file target="*-Info.plist" parent="UIBackgroundModes">
            <array>
                $BACKGROUND_MODE_LOCATION
            </array>
        </config-file>

        <config-file target="config.xml" parent="/*">
            <feature name="BackgroundGeolocation">
                <param name="ios-package" value="CDVBackgroundGeolocation"/>
            </feature>
        </config-file>

        <podspec>
            <config>
                <source url="https://cdn.cocoapods.org/"/>
            </config>
            <pods use-frameworks="true">
                <!-- (WO-194) 4.9.0 is the first TSLocationManager that accepts TSBackgroundFetch 4.2, at iOS 15:
                     apps need <preference name="deployment-target" value="15.0" />. -->
                <!-- (WO-195) nospm: cordova-ios 8 skips this pod and uses Package.swift; the twin of its
                     native-background-geolocation requirement, so change both together. -->
                <pod name="TSLocationManager" spec="~> 4.9.0" nospm="true"/>
            </pods>
        </podspec>

        <source-file src="src/ios/CDVBackgroundGeolocation.m" />
        <header-file src="src/ios/CDVBackgroundGeolocation.h" />
     </platform>

     <!-- android -->
    <platform name="android">
        <preference name="GOOGLE_API_VERSION" default="21.3.0" />
        <preference name="TSLOCATIONMANAGER_VERSION" default="4.7.+" />
        <preference name="EVENTBUS_VERSION" default="3.3.1" />
        <framework src="org.greenrobot:eventbus:$EVENTBUS_VERSION"/>

        <framework src="src/android/build.gradle" custom="true" type="gradleReference" />

        <source-file src="src/android/CDVBackgroundGeolocation.java" target-dir="src/com/transistorsoft/cordova/bggeo" />

        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="BackgroundGeolocation">
                <param name="android-package" value="com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation"/>
            </feature>
        </config-file>
     </platform>

     <!-- Browser (mock) -->
     <platform name="browser">
        <config-file target="config.xml" parent="/*">
            <feature name="BackgroundGeolocation"></feature>
        </config-file>
        <js-module src="src/browser/BackgroundGeolocationMock.js" name="BackgroundGeolocationMock">
            <runs/>
        </js-module>
     </platform>

</plugin>
