<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
           id="cordova-plugin-firebase-crash"
      version="8.0.2">

    <name>cordova-plugin-firebase-crash</name>
    <description>Cordova plugin for Firebase Crashlytics</description>
    <license>MIT</license>
    <keywords>cordova</keywords>
    <repo>https://github.com/chemerisuk/cordova-plugin-firebase-crash</repo>
    <issue>https://github.com/chemerisuk/cordova-plugin-firebase-crash/issues</issue>

    <engines>
        <engine name="cordova" version=">=10.0.0"/>
        <engine name="cordova-android" version=">=11.0.0"/>
        <engine name="cordova-ios" version=">=6.0.0"/>
    </engines>

    <js-module src="www/FirebaseCrash.js" name="FirebaseCrash">
        <merges target="cordova.plugins.firebase.crashlytics" />
    </js-module>

    <preference name="CRASHLYTICS_COLLECTION_ENABLED" default="true" />

    <platform name="ios">
        <preference name="IOS_FIREBASE_POD_VERSION" default="10.17.0" />

        <hook type="before_plugin_uninstall" src="hooks/ios/before_plugin_uninstall.js" />

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

        <!--
            use a bit hacky method to set boolean value as a string:
            https://developer.apple.com/documentation/foundation/nsstring/1409420-boolvalue?preferredLanguage=occ
        -->
        <config-file target="*-Info.plist" parent="FirebaseCrashlyticsCollectionEnabled">
            <string>$CRASHLYTICS_COLLECTION_ENABLED</string>
        </config-file>

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

        <podspec>
            <config>
                <source url="https://cdn.cocoapods.org/"/>
            </config>
            <pods use-frameworks="true">
                <pod name="Firebase/Crashlytics" spec="$IOS_FIREBASE_POD_VERSION" />
            </pods>
        </podspec>
    </platform>

    <platform name="android">
        <preference name="ANDROID_FIREBASE_BOM_VERSION" default="32.5.0" />

        <config-file parent="/*" target="res/xml/config.xml">
            <feature name="FirebaseCrash">
                <param name="android-package" value="by.chemerisuk.cordova.firebase.FirebaseCrashPlugin" />
                <param name="onload" value="true" />
            </feature>
        </config-file>

        <config-file target="config.xml" parent="/*">
            <preference name="AndroidXEnabled" value="true" />
            <preference name="GradlePluginGoogleServicesEnabled" value="true" />
            <preference name="GradlePluginGoogleServicesVersion" value="4.4.0" />
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.INTERNET" />
  		</config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="$CRASHLYTICS_COLLECTION_ENABLED" />
        </config-file>

        <source-file src="src/android/FirebaseCrashPlugin.java" target-dir="src/by/chemerisuk/cordova/firebase/" />

        <dependency id="cordova-support-android-plugin" version="~2.0.4" />

        <framework src="platform('com.google.firebase:firebase-bom:$ANDROID_FIREBASE_BOM_VERSION')" />
        <framework src="com.google.firebase:firebase-crashlytics" />
        <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
    </platform>

</plugin>
