<?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="com.transistorsoft.cordova.background-geolocation"
    version="0.5.4">
    <name>BackgroundGeolocation</name>
    <description>Sophisticated, battery-efficient background-geolocation plugin for Cordova</description>
    <license>MIT</license>
    <keywords>cordova, phonegap, background geolocation</keywords>

    <engines>
        <engine name="cordova" version=">=3.0.0" />
    </engines>

    <!-- 
        Pre-Cordova 5, non-npm plugin reference.  Uncomment this if you're not using Cordova 5.
    <dependency id="org.apache.cordova.dialogs" />
    -->

    <!-- Cordova 5 npm-style plugin referernce.  Comment this out if you're not using Cordova 5 -->
    <dependency id="cordova-plugin-dialogs" />

    <js-module src="www/BackgroundGeolocation.js" name="BackgroundGeolocation">
        <clobbers target="window.BackgroundGeolocation" />
    </js-module>

    <!-- android -->
    <platform name="android">
        <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
        <resource-file src="src/android/libs/tslocationmanager.aar" target="src/android/libs/tslocationmanager.aar" />

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

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <service android:name="com.transistorsoft.locationmanager.BackgroundGeolocationService" />
            <service android:name="com.transistorsoft.locationmanager.LocationService" />
            <service android:name="com.transistorsoft.locationmanager.ActivityRecognitionService" />
            <service android:name="com.transistorsoft.locationmanager.GeofenceService" />
            <receiver android:name="com.transistorsoft.locationmanager.BootReceiver" android:enabled="true" android:exported="false">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED"/>
                </intent-filter>
            </receiver>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest">
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <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_LOCATION_EXTRA_COMMANDS" />
            <uses-permission android:name="android.permission.INTERNET" />
            <uses-permission android:name="android.permission.WAKE_LOCK" />
            <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

        </config-file>   
        <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>          

     <platform name="ios">
        <!-- required background modes:  App registers for location updates -->
        
        <config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
            <string>TSLocationManager requires background location tracking</string>
        </config-file>

        <config-file target="*-Info.plist" parent="UIBackgroundModes">
            <array>
                <string>location</string>
            </array>
        </config-file>

        <config-file target="config.xml" parent="/*">
            <feature name="BackgroundGeolocation">
                <param name="ios-package" value="CDVBackgroundGeolocation"/>
            </feature>
        </config-file>
        <framework src="AudioToolbox.framework" weak="true" />
        <framework src="AVFoundation.framework" weak="true" />
        <framework src="libsqlite3.dylib" weak="true" />
        <framework src="src/ios/TSLocationManager.framework" custom="true" />
        <source-file src="src/ios/CDVBackgroundGeolocation.m" />
        <header-file src="src/ios/CDVBackgroundGeolocation.h" />
     </platform>          

	<!-- wp8 -->
	<platform name="wp8">
		<config-file target="config.xml" parent="/*">
			<feature name="BackgroundGeoLocation">
				<param name="wp-package" value="BackgroundGeoLocation" onload="true" />
				<param name="onload" value="true" />
			</feature>
		</config-file>

		<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Tasks/DefaultTask">
			<BackgroundExecution>
				<ExecutionType Name="LocationTracking" />
			</BackgroundExecution>
		</config-file>

		<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
			<Capability Name="ID_CAP_LOCATION" />
		</config-file> 
		<source-file src="src/wp8/BackgroundGeoLocation.cs" />
		<source-file src="src/wp8/BackgroundGeoLocationOptions.cs" />
		<source-file src="src/wp8/DebugAudioNotifier.cs" />
		<source-file src="src/wp8/ExtensionMethods.cs" />
		<source-file src="src/wp8/IBackgroundGeoLocation.cs" /> 
	</platform>

</plugin>
