<?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.1">
    <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>

    <dependency id="org.apache.cordova.dialogs" />

    <js-module src="www/BackgroundGeoLocation.js" name="BackgroundGeoLocation">
        <clobbers target="plugins.backgroundGeoLocation" />
    </js-module>

    <!-- android -->
    <platform name="android">
        <framework src="com.google.android.gms:play-services-location:7.3.0" />
        <source-file src="src/android/libs/eventbus-2.4.0.jar" target-dir="libs" />
        <source-file src="src/android/libs/transistor-locationmanager.jar" target-dir="libs" />
        <source-file src="src/android/CDVBackgroundGeolocation.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>This app 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>
