<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:rim="http://www.blackberry.com/ns/widgets"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="cordova-plugin-uamap"
    version="1.1.2">
    <name>cordova-plugin-uamap</name>
    <description>Cordova Location Plugin By AMap</description>
    <license>Apache 2.0</license>
    <keywords>cordova,location, AMap</keywords>

    <preference name="AMAP_ANDROID_KEY" />
    <preference name="AMAP_IOS_KEY" />

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

    <js-module name="AMapLocation" src="www/location.js">
        <clobbers target="cordova.plugins.AMapLocation" />
    </js-module>

    <!-- android -->
    <platform name="android">
        <config-file parent="/*" target="res/xml/config.xml">
            <feature name="AMapLocation">
                <param name="android-package" value="unic.cicoco.cordova.amap.Location" />
            </feature>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/*">
            <!--用于进行网络定位-->
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
            <!--用于访问GPS定位-->
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
            <!--用于获取运营商信息，用于支持提供运营商信息相关的接口-->
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
            <!--用于访问wifi网络信息，wifi信息会用于进行网络定位-->
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
            <!--用于获取wifi的获取权限，wifi信息会用来进行网络定位-->
            <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
            <!--用于访问网络，网络定位需要上网-->
            <uses-permission android:name="android.permission.INTERNET"></uses-permission>
            <!--用于读取手机当前的状态-->
            <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
            <!--用于写入缓存数据到扩展存储卡-->
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
            <!--用于申请调用A-GPS模块-->
            <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
            <!--如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限-->
            <!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> -->
            <!--如果您的应用需要后台定位权限，且有可能运行在Android Q设备上,并且设置了target>28，必须增加这个权限声明-->
            <!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> -->
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <service android:name="com.amap.api.location.APSService"></service>   
            <meta-data android:name="com.amap.api.v2.apikey" android:value="$AMAP_ANDROID_KEY"></meta-data> 
        </config-file>
        <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
        <source-file src="src/android/Location.java" target-dir="src/unic/cicoco/cordova/amap" />
    </platform>

    <!-- ios -->
    <platform name="ios">
        <config-file target="config.xml" parent="/*">
            <feature name="AMapLocation">
                <param name="ios-package" value="AMapLocation" />
            </feature>
        </config-file>

        <config-file target="*-Info.plist" parent="AMapAppKey">
          <string>$AMAP_IOS_KEY</string>
        </config-file>

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

        <framework src="src/ios/lib/AMapFoundationKit.framework"  custom="true"/>
        <framework src="src/ios/lib/AMapLocationKit.framework"  custom="true"/>
        <framework src="src/ios/lib/MAMapKit.framework"  custom="true"/>
        <framework src="GLKit.framework" />
        <framework src="ExternalAccessory.framework" />
        <framework src="SystemConfiguration.framework" />
        <framework src="CoreTelephony.framework" />
        <framework src="Security.framework" />
        <framework src="libz.tbd" />
        <framework src="libc++.tbd" />
    </platform>
</plugin>
