<?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="com-infobip-plugins-mobilemessaging"
	version="8.3.0">

	<name>MobileMessagingCordova</name>
	<keywords>Infobip,push,cordova</keywords>
	<engines>
        <engine name="cordova-android" version=">=4.1.0"/>
        <engine name="cordova-ios" version=">=7.0.0"/>
    </engines>
	<dependency id="cordova-custom-config"/>

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

	<hook type="before_build" src="scripts/hms_fix_dependencies.js"/>
	<hook type="after_plugin_add" src="scripts/installDependencies.js"/>
	<hook type="after_prepare" src="scripts/android_fix_google_app_id.js"/>
	<hook type="after_prepare" src="scripts/integrate_notification_extension.js"/>

	<preference name="ANDROID_SUPPORT_VER_OVERRIDE" default="false" />
	<preference name="ANDROID_GMS_VER_OVERRIDE" default="false" />
	<preference name="ANDROID_FIREBASE_VER_OVERRIDE" default="false" />

	<platform name="ios">
		<config-file parent="UIBackgroundModes" target="*-Info.plist">
            <array>
                <string>remote-notification</string>
            </array>
        </config-file>

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

		<config-file parent="aps-environment" target="*/Entitlements-Debug.plist">
            <string>development</string>
        </config-file>

        <config-file parent="aps-environment" target="*/Entitlements-Release.plist">
            <string>production</string>
        </config-file>

		<config-file parent="com.apple.developer.icloud-services" target="*/Entitlements-Debug.plist">
			<array><string>CloudDocuments</string></array>
		</config-file>

		<config-file parent="com.apple.developer.icloud-services" target="*/Entitlements-Release.plist">
			<array><string>CloudDocuments</string></array>
		</config-file>

		<podspec>

            <pods use-frameworks="true">
                <pod name="MobileMessaging" spec="15.0.0" />
                <pod name="MobileMessaging/InAppChat" spec="15.0.0" />
                <pod name="MobileMessaging/Inbox" spec="15.0.0" />
            </pods>
		</podspec>
		<header-file src="src/ios/MobileMessagingCordova-Bridging-Header.h" type="BridgingHeader" />
		<source-file src="src/ios/MobileMessagingCordova.swift" />
		<source-file src="src/ios/InfobipMobileMessagingCordovaLogger.swift" />
	</platform>

	<platform name="android">
		<config-file target="config.xml" parent="/*">
			<feature name="MobileMessagingCordova">
				<param name="android-package" value="org.apache.cordova.plugin.MobileMessagingCordova"/>
			</feature>
			<preference name="IB_ANDROID_SUPPORT_VER_OVERRIDE" value="$ANDROID_SUPPORT_VER_OVERRIDE"/>
			<preference name="IB_ANDROID_GMS_VER_OVERRIDE" value="$ANDROID_GMS_VER_OVERRIDE"/>
			<preference name="IB_ANDROID_FIREBASE_VER_OVERRIDE" value="$ANDROID_FIREBASE_VER_OVERRIDE"/>
			<preference name="IB_ENABLE_HMS_SUPPORT" value="$ENABLE_HMS_SUPPORT"/>
			<preference name="IB_ANDROID_USE_CRYPTOR_MIGRATION" value="$ANDROID_USE_CRYPTOR_MIGRATION"/>
		</config-file>

		<config-file target="AndroidManifest.xml" parent="/manifest/application">
		    <receiver android:name="org.apache.cordova.plugin.MobileMessagingCordova$MessageActionReceiver" android:exported="false">
	            <intent-filter>
	                <action android:name="org.infobip.mobile.messaging.MESSAGE_RECEIVED" />
	                <action android:name="org.infobip.mobile.messaging.NOTIFICATION_TAPPED" />
	            </intent-filter>
	        </receiver>
		</config-file>

		<framework src="libs/android/mobile-messaging-aar.gradle" custom="true" type="gradleReference" />
		<framework src="com.google.android.material:material:1.13.0"/>
		<framework src="androidx.exifinterface:exifinterface:1.4.1"/>
		<framework src="androidx.core:core-ktx:1.16.0"/>
		<framework src="androidx.lifecycle:lifecycle-runtime-ktx:2.9.3"/>
		<source-file src="src/android/MobileMessagingCordova.java" target-dir="src/org/apache/cordova/plugin"/>
		<source-file src="src/android/CordovaLogger.java" target-dir="src/org/apache/cordova/plugin"/>
		<source-file src="src/android/CordovaLogWriter.java" target-dir="src/org/apache/cordova/plugin"/>
	</platform>

</plugin>
