﻿<?xml version="1.0" encoding="UTF-8"?>
<!-- 
Copyright (C) 2024 Acoustic, L.P. All rights reserved.

NOTICE: This file contains material that is confidential and proprietary to 
Acoustic, L.P. and/or other developers. No license is granted under any intellectual or 
industrial property rights of Acoustic, L.P. except as may be provided in an agreement with 
Acoustic, L.P. Any unauthorized copying or distribution of content from this file is prohibited.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-acoustic-mobile-push" version="3.9.144">
    <name>Acoustic MCE Cordova Plugin</name>
    <author>Acoustic MCE</author>
    <description>Allows Cordova applications to integrate with Acoustic MCE Push Services</description>
    <keywords>mce</keywords>
    <license>Apache 2.0 License</license>
    <engines>
        <engine name="cordova" version=">=3.0" />
    </engines>
    <js-module src="www/js/MCEPlugin.js" name="MCEPlugin">
        <clobbers target="MCEPlugin" />
    </js-module>

    <!-- Library settings -->
    <preference name="POD_VERSION" default="3.9.144" />

    <preference name="CHANNEL_NAME" default="MCE SDK Notification Channel" />
    <preference name="CHANNEL_DESCRIPTION" default="This is the notification channel for the MCE SDK sample application"/>
    <preference name="CHANNEL_ID" default="mce_sample_channel"/>

    <preference name="LOGLEVEL" default="error" />
    <preference name="SERVER_URL" default="https://mobile-sdk-lib-us-1.brilliantcollector.com" />
    <preference name="IOS_PROD_APPKEY" />
    <preference name="IOS_DEV_APPKEY" />
    <preference name="INVALIDATE_EXISTING_USER" default="false" />
    <preference name="AUTO_REINITIALIZE" default="true" />
    <preference name="AUTO_INITIALIZE" default="true" />
    <preference name="ANDROID_APPKEY" />
    <platform name="ios">
        <framework src="CoreTelephony.framework" />
        <framework src="CoreLocation.framework" />
        <framework src="libsqlite3.dylib" />
        <header-file src="src/ios/AppDelegate+MCE.h" />
        <source-file src="src/ios/AppDelegate+MCE.m" />
        <header-file src="src/ios/MCEManualConfiguration.h" />
        <source-file src="src/ios/MCEManualConfiguration.m" />
        <header-file src="src/ios/MCEPlugin.h" />
        <source-file src="src/ios/MCEPlugin.m" />
        <header-file src="src/ios/MCEEventCallbackQueue.h" />
        <source-file src="src/ios/MCEEventCallbackQueue.m" />
        <config-file target="config.xml" parent="/*">
            <feature name="MCEPlugin">
                <param name="ios-package" value="MCEPlugin"/>
            </feature>
            <preference name="baseUrl" value="$SERVER_URL" />
            <preference name="prodAppKey" value="$IOS_PROD_APPKEY" />
            <preference name="devAppKey" value="$IOS_DEV_APPKEY" />
            <preference name="autoInitialize" value="$AUTO_INITIALIZE" />
            <preference name="loglevel" value="$LOGLEVEL" />
            <preference name="invalidateExistingUser" value="$INVALIDATE_EXISTING_USER" />
            <preference name="autoReinitialize" value="$AUTO_REINITIALIZE" />
        </config-file>
        <config-file target="*-Info.plist" parent="UIBackgroundModes">
            <array>
                <string>remote-notification</string>
            </array>
        </config-file>

        <config-file target="*-Info.plist" parent="NSLocationAlwaysAndWhenInUseUsageDescription">
            <string>Be notified when interesting things are nearby</string>
        </config-file>
        <config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
            <string>Be notified when interesting things are nearby</string>
        </config-file>
        <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
            <string>Be notified when interesting things are nearby</string>
        </config-file>
        <podspec>
            <config>
                <source url="https://cdn.cocoapods.org/"/>
            </config>
            <pods use-frameworks="true">
                <pod name="AcousticMobilePushDebug"  />
            </pods>
        </podspec>
    </platform>
    <platform name="android">
        <hook type="after_prepare" src="src/android/hooks/add_tools_namespace.js" />
        <hook type="after_prepare" src="src/android/hooks/after_prepare.js" />

        <framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />

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

        <config-file target="AndroidManifest.xml" parent="/manifest">
            <!-- POST_NOTIFICATIONS is required for notifications -->
            <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
            <!-- INTERNET is required for calling the MCE server -->
            <uses-permission android:name="android.permission.INTERNET" />
            <!-- WAKE_LOC is required for running scheduled tasks -->
            <uses-permission android:name="android.permission.WAKE_LOCK" />
            <!-- RECEIVE_BOOT_COMPLETED is required for performing SDK task on device startup -->
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
            <!-- VIBRATE is required for notification configuration -->
            <uses-permission android:name="android.permission.VIBRATE" />
            <!-- CALL_PHONE is optional. It is only required is the dial action is used -->
            <uses-permission android:name="android.permission.CALL_PHONE" android:required="false" />
            
            <queries>
                <!-- Required for handling notifications that open the device's dialer app -->
                <intent>
                    <action android:name="android.intent.action.DIAL" />
                </intent>
                <!-- Required for handling notifications that open the device -->
                <intent>
                    <action android:name="android.intent.action.VIEW"/>
                    <data android:scheme="https"/>
                </intent>
            </queries>
        </config-file>

        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <!-- This is required for google play services -->
            <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
            <!-- MCE API26 properties -->
            <meta-data android:name="channelName" android:value="$CHANNEL_NAME" />
            <meta-data android:name="channelDescription" android:value="$CHANNEL_DESCRIPTION" />
            <meta-data android:name="channelId" android:value="$CHANNEL_ID" />
            <!-- MCE properties -->
            <meta-data android:name="messagingService" android:value="fcm" />
            <meta-data android:name="mceSenderId" android:value="" />
            <meta-data android:name="autoInitialize" android:value="$AUTO_INITIALIZE" />
            <meta-data android:name="autoReinitialize" android:value="$AUTO_REINITIALIZE" />
            <meta-data android:name="mceAppKey" android:value="@string/appkey" />
            <meta-data android:name="loglevel" android:value="$LOGLEVEL" />
            <meta-data android:name="mceSessionEnabled" android:value="true" />
            <meta-data android:name="mceSessionDuration" android:value="5" />
            <meta-data android:name="mceServer" android:value="$SERVER_URL" />
            <meta-data android:name="invalidateExistingUser" android:value="$INVALIDATE_EXISTING_USER" />
            <receiver android:exported="false" android:name="co.acoustic.mobile.push.sdk.js.JsonMceBroadcastReceiver">
                <intent-filter>
                    <action android:name="co.acoustic.mobile.push.sdk.NOTIFIER" />
                </intent-filter>
            </receiver>
            <!-- AlarmReceiver is required for SDK scheduled tasks and device status updates -->
            <receiver android:exported="false" android:name="co.acoustic.mobile.push.sdk.wi.AlarmReceiver">
                <intent-filter>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                </intent-filter>
                <intent-filter>
                    <action android:name="android.intent.action.TIMEZONE_CHANGED" />
                </intent-filter>
                <intent-filter>
                    <action android:name="android.intent.action.PACKAGE_REPLACED" />
                    <data android:scheme="package" />
                </intent-filter>
                <intent-filter>
                    <action android:name="android.intent.action.LOCALE_CHANGED" />
                </intent-filter>
            </receiver>
            <!-- NotifActionReceiver is required for notification handling -->
            <receiver android:exported="false" android:name="co.acoustic.mobile.push.sdk.notification.NotifActionReceiver" />
            <!-- The provider is needed for the SDK database -->
            <provider android:name="co.acoustic.mobile.push.sdk.db.Provider" android:authorities="$PACKAGE_NAME.MCE_PROVIDER" android:exported="false" />
            <provider android:name="co.acoustic.mobile.push.sdk.js.Provider" android:authorities="$PACKAGE_NAME.MCE_JSON_PROVIDER" android:exported="false" />
            <service android:name="co.acoustic.mobile.push.sdk.session.SessionTrackingIntentService"/>
            <!-- EventsAlarmListener is required for event handling -->
            <service android:name="co.acoustic.mobile.push.sdk.events.EventsAlarmListener" />
            <!-- PhoneHomeIntentService is required to allow the client to contact the server to update state -->
            <service android:name="co.acoustic.mobile.push.sdk.registration.PhoneHomeIntentService" />
            <!-- RegistrationIntentService is required for SDK registration -->
            <service android:name="co.acoustic.mobile.push.sdk.registration.RegistrationIntentService" />
            <!-- AttributesQueueConsumer is required for attributes handling -->
            <service android:name="co.acoustic.mobile.push.sdk.attributes.AttributesQueueConsumer" />
            <!-- InboxUpdateService is optional. It is used for retrieving inbox updates from the MCE server. It is required only if inbox is used -->
            <service android:name="co.acoustic.mobile.push.sdk.plugin.inbox.InboxUpdateService" />
            <!-- FCM Messages -->
            <service android:exported="false" android:name="co.acoustic.mobile.push.sdk.messaging.fcm.FcmMessagingService">
                <intent-filter>
                    <action android:name="com.google.firebase.MESSAGING_EVENT" />
                </intent-filter>
            </service>
            <!-- MdeJobService is used for launching a job while the app is in the foreground. This is only used in Android O and above -->
            <service android:name="co.acoustic.mobile.push.sdk.job.MceJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
        </config-file>

        
        <config-file target="res/values/strings.xml" parent="/*">
            <string name="appkey">$ANDROID_APPKEY</string>
            <string name="senderid"></string>
        </config-file>
        <config-file target="res/xml/config.xml" parent="/widget">
            <feature name="MCEPlugin">
                <param name="android-package" value="co.acoustic.mobile.push.plugin.cordova.MceCordovaPlugin" />
            </feature>
        </config-file>
        
        <source-file src="src/android/src/co/acoustic/mobile/push/plugin/cordova/CordovaJsonCallback.java" target-dir="co/acoustic/mobile/push/plugin/cordova" />
        <source-file src="src/android/src/co/acoustic/mobile/push/plugin/cordova/MceCordovaPlugin.java" target-dir="co/acoustic/mobile/push/plugin/cordova" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/format" target-dir="java/co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/JsonCallback.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/JsonCallbacksRegistry.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/JsonDbAdapter.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/JsonMceBroadcastReceiver.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/JsonNotificationAction.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/MceJsonApi.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/MceJsonApplication.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/MceJsonSdk.java" target-dir="co/acoustic/mobile/push/sdk/js" />
        <source-file src="src/android/src/co/acoustic/mobile/push/sdk/js/Provider.java" target-dir="co/acoustic/mobile/push/sdk/js" />
    </platform>
</plugin>
