<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="apptentive-cordova" version="6.9.3">

    <name>Apptentive</name>
    <description>Apptentive Plugin For Cordova</description>
    <keywords>apptentive</keywords>
    <engines>
      <engine name="cordova" version=">=10.0.1"/>
      <engine name="cordova-android" version=">=9.0.0"/>
    </engines>

    <!-- android -->
    <platform name="android">
        <!-- Require API key -->
        <preference name="ANDROID_APP_KEY"/>
        <preference name="ANDROID_APP_SIGNATURE"/>

        <!-- Apptentive Configuration Items -->
        <preference name="ANDROID_INHERIT_APP_THEME" default="false"/>
        <preference name="ANDROID_LOG_LEVEL" default="info"/>
        <preference name="ANDROID_USES_DEVICE_ENCRYPTION" default="false"/>
        <preference name="ANDROID_SANITIZE_LOG_MESSAGES" default="true"/>
        <preference name="ANDROID_CUSTOM_APP_STORE_URL" default=" "/>
        <preference name="ANDROID_RATING_INTERACTION_THROTTLE_LENGTH" default="604800000"/>

        <!-- Define namespace for javascript reference -->
        <js-module src="www/Apptentive.js" name="Apptentive">
            <clobbers target="Apptentive"/>
        </js-module>

        <!-- Setup Cordova config.xml file -->
        <config-file target="res/xml/config.xml" parent="/*">
          <preference name="GradlePluginKotlinEnabled" value="true"/>
          <preference name="GradlePluginKotlinVersion" value="1.7.20"/>
          
          <feature name="ApptentiveBridge">
              <param name="android-package" value="com.apptentive.cordova.ApptentiveBridge"/>
          </feature>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/*">
            <!-- Make sure to support high resolution screens so Apptentive's UI looks great. -->
            <supports-screens android:xlargeScreens="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="application">
            <meta-data android:name="apptentive_key" android:value="$ANDROID_APP_KEY"/>
            <meta-data android:name="apptentive_signature" android:value="$ANDROID_APP_SIGNATURE"/>
            <meta-data android:name="apptentive_log_level" android:value="$ANDROID_LOG_LEVEL"/>
            <meta-data android:name="apptentive_inherit_app_theme" android:value="$ANDROID_INHERIT_APP_THEME"/>
            <meta-data android:name="apptentive_uses_encryption" android:value="$ANDROID_USES_DEVICE_ENCRYPTION"/>            
            <meta-data android:name="apptentive_custom_app_store_url" android:value="$ANDROID_CUSTOM_APP_STORE_URL"/>
            <meta-data android:name="apptentive_sanitize_log_messages" android:value="$ANDROID_SANITIZE_LOG_MESSAGES"/>
            <meta-data android:name="apptentive_rating_interaction_throttle_length" android:value="$ANDROID_RATING_INTERACTION_THROTTLE_LENGTH"/>
        </config-file>

        <framework src="com.apptentive:apptentive-kit-android:6.9.3"/>
        <source-file src="src/android/ApptentiveBridge.kt" target-dir="app/src/main/kotlin/com/apptentive/cordova"/>
        <source-file src="src/android/JsonHelper.kt" target-dir="app/src/main/kotlin/com/apptentive/cordova"/>
        <source-file src="src/android/Util.kt" target-dir="app/src/main/kotlin/com/apptentive/cordova"/>
    </platform>


    <!-- ios -->
    <platform name="ios">
        <!-- Require API key -->
        <preference name="IOS_APP_KEY"/>
        <preference name="IOS_APP_SIGNATURE"/>

        <!-- Apptentive Configuration Items -->
        <preference name="IOS_SANITIZE_LOG_MESSAGES" default="true"/>

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

        <config-file target="config.xml" parent="/widget">
            <feature name="ApptentiveBridge">
                <param name="ios-package" value="ApptentiveBridge"/>
            </feature>
        </config-file>

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

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

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

        <!-- ApptentiveBridge -->
        <header-file src="src/ios/ApptentiveBridge-Bridging-Header.h" type="BridgingHeader"/>
        <source-file src="src/ios/ApptentiveBridge.swift" target-dir="Apptentive"/>

        <!-- required system frameworks -->
        <framework src="Accelerate.framework" weak="true"/>
        <framework src="CoreData.framework" weak="true"/>
        <framework src="CoreTelephony.framework" weak="true"/>
        <framework src="CoreText.framework" weak="true"/>
        <framework src="Foundation.framework" weak="true"/>
        <framework src="QuartzCore.framework" weak="true"/>
        <framework src="Storekit.framework" weak="true"/>
        <framework src="SystemConfiguration.framework" weak="true"/>
        <framework src="UIKit.framework" weak="true"/>

        <podspec>
            <config>
                <source url="https://github.com/CocoaPods/Specs.git"/>
            </config>
            <pods use-frameworks="true">
                <pod name="ApptentiveKit" spec="~&gt; 6.9.1" swift-version="5"/>
            </pods>
        </podspec>
    </platform>

</plugin>
