<?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="cordova-plugin-background-fetch"
    version="7.3.1">
    <name>CDVBackgroundFetch</name>
    <description>Cordova Background Fetch Plugin</description>
    <license>MIT</license>
    <repo>https://github.com/christocracy/cordova-plugin-background-fetch</repo>
    <issue>https://github.com/christocracy/cordova-plugin-background-fetch/issues</issue>
    <keywords>phonegap,cordova,background fetch</keywords>

    <engines>
        <engine name="cordova" version=">=7.1.0" />
        <engine name="cordova-android" version=">=7.0.0"/>
        <engine name="cordova-ios" version=">=5.0.0"/>
    </engines>

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

    <platform name="ios">
        <!-- Add BGTaskSchedulerPermittedIdentifiers com.transistorsoft.fetch -->
        <config-file target="*-Info.plist" parent="BGTaskSchedulerPermittedIdentifiers">
            <array>
                <string>com.transistorsoft.fetch</string>
            </array>
        </config-file>

        <!-- required background modes:  App registers for location updates -->
        <config-file target="*-Info.plist" parent="UIBackgroundModes">
            <array>
                <string>fetch</string>
                <string>processing</string>
            </array>
        </config-file>

        <config-file target="config.xml" parent="/*">
            <feature name="BackgroundFetch">
                <param name="ios-package" value="CDVBackgroundFetch"/>
                <param name="onload" value="true"/>
            </feature>
        </config-file>

        <podspec>
            <config>
                <source url="https://cdn.cocoapods.org/"/>
            </config>
            <pods use-frameworks="true">
                <pod name="TSBackgroundFetch" spec="~> 4.1.0"/>
            </pods>
        </podspec>

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

    <platform name="android">

        <source-file src="src/android/CDVBackgroundFetch.java" target-dir="src/com/transistorsoft/cordova/backgroundfetch" />

        <source-file src="src/android/HeadlessTask.java" target-dir="src/com/transistorsoft/cordova/backgroundfetch" />
        <framework src="androidx.lifecycle:lifecycle-runtime:2.7.+" />
        <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="BackgroundFetch">
                <param name="android-package" value="com.transistorsoft.cordova.backgroundfetch.CDVBackgroundFetch"/>
            </feature>
        </config-file>
    </platform>

</plugin>
