<?xml version='1.0' encoding='utf-8'?>
<plugin id="com.commontime.cordova.beacon" version="1.0.6" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">

    <name>Proximity Beacon Plugin</name>
    <description>Proximity Beacon Monitoring and Transmission Plugin (supporting iBeacons)</description>
    <license>MIT</license>
    <keywords>cordova,ibeacon,beacon,bluetooth,le</keywords>
    <repo>https://github.com/commontime/com.commontime.cordova.beacon</repo>

    <!-- Third party libraries -->
    <js-module name="underscorejs" src="www/lib/underscore-min-1.6.js">
        <runs/>
    </js-module>
  
    <js-module name="Q" src="www/lib/q.min.js">
        <runs/>
    </js-module>
    
    <!-- Plugin source code: Core -->
    <js-module name="LocationManager" src="www/LocationManager.js">
        <!-- see http://cordova.apache.org/docs/en/3.0.0/plugin_ref_spec.md#Plugin%20Specification_js_module_element -->
        <!-- We have to use clobers but with cordova.plugins.locationManager or if you'd like to merge you need to user merges to make alle objects acessable -->
        <merges target="cordova.plugins"/>
    </js-module>

    <js-module name="Delegate" src="www/Delegate.js">
        <runs/>
    </js-module>

    <!-- Plugin source code: Model -->
    <js-module name="Region" src="www/model/Region.js">
        <runs/>
    </js-module>

    <js-module name="Regions" src="www/Regions.js">
        <runs/>
    </js-module>

    <js-module name="CircularRegion" src="www/model/CircularRegion.js">
        <runs/>
    </js-module>

    <js-module name="BeaconRegion" src="www/model/BeaconRegion.js">
        <runs/>
    </js-module>


    <platform name="ios">
        
        <config-file parent="/*" target="config.xml">
            <feature name="LocationManager">
                <param name="ios-package" value="CDVLocationManager"/>
            </feature>
        </config-file>
        
        <preference name="LOCATION_ALWAYS_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
            <string>$LOCATION_ALWAYS_USAGE_DESCRIPTION</string>
        </config-file>

        <preference name="LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
            <string>$LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION</string>
        </config-file>

        <preference name="BLUETOOTH_PERIPHERAL_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSBluetoothPeripheralUsageDescription">
            <string>$BLUETOOTH_PERIPHERAL_USAGE_DESCRIPTION</string>
        </config-file>

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

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

        <header-file src="src/ios/AppDelegate+CDVLocationManager.h"/>
        <source-file src="src/ios/AppDelegate+CDVLocationManager.m"/>

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

        <framework src="CoreBluetooth.framework" />
        <framework src="CoreLocation.framework" />

    </platform>

    <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="LocationManager" >
                <param name="android-package" value="com.commontime.plugin.LocationManager"/>
                <param name="onload" value="true" />
            </feature>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest">
			<uses-permission android:name="android.permission.BLUETOOTH" />
            <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
			<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
			<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
			<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver" >
				<intent-filter>
					<action android:name="android.intent.action.BOOT_COMPLETED" />
					<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
					<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
				</intent-filter>
			</receiver>
            <service android:enabled="true"
                     android:exported="true"
                     android:isolatedProcess="false"
                     android:label="iBeacon"
                     android:name="org.altbeacon.beacon.service.BeaconService">
            </service>
            <service android:enabled="true"
                     android:name="org.altbeacon.beacon.BeaconIntentProcessor">
                <meta-data android:name="background" android:value="true" />
                <intent-filter android:priority="1" >
                    <action android:name="com.commontime.plugin.IBeaconPlugin.DID_RANGING" />
                    <action android:name="com.commontime.plugin.IBeaconPlugin.DID_MONITORING" />
                </intent-filter>
            </service>
        </config-file>
		
        <source-file src="src/android/LocationManager.java" target-dir="src/com/commontime/plugin/" />
        <source-file src="src/android/IBeaconServiceNotifier.java" target-dir="src/com/commontime/plugin/" />
        <source-file src="src/android/ILocationManagerCommand.java" target-dir="src/com/commontime/plugin/" />
        <source-file src="src/android/PausableThreadPoolExecutor.java" target-dir="src/com/commontime/plugin/" />

		<source-file src="libs/android/altbeacon.jar" target-dir="libs" framework="true" />
    </platform>

</plugin>
