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

    <name>MiPush</name>
    <description>Cordova MiPush Plugin</description>
    <author>https://github.com/wenin819</author>
    <license>Apache 2.0</license>
    <keywords>cordova,mipush</keywords>

    <engines>
        <engine name="cordova" version=">=3.0" />
    </engines>

    <preference name="MI_PUSH_APP_KEY"/>
    <preference name="MI_PUSH_APP_ID" />
    <preference name="MI_PUSH_APP_IOS_KEY"/>
    <preference name="MI_PUSH_APP_IOS_ID" />

    <!-- dependencies -->
    <dependency id="cordova-plugin-device" />

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

    <platform name="ios">
        <config-file target="config.xml" parent="/*">
            <feature name="MiPushPlugin">
                <param name="ios-package" value="MiPushPlugin" />
                <param name="onload" value="true" />
            </feature>
        </config-file>
        <config-file target="*-Info.plist" parent="MiSDKAppID">
            <string>$MI_PUSH_APP_IOS_ID</string>
        </config-file>
        <config-file target="*-Info.plist" parent="MiSDKAppKey">
            <string>$MI_PUSH_APP_IOS_KEY</string>
        </config-file>
        <config-file target="*-Info.plist" parent="MiSDKRun">
            <string>Online</string>
        </config-file>

        <header-file src="src/ios/Plugins/MiPushPlugin.h" />
        <source-file src="src/ios/Plugins/MiPushPlugin.m" />
        <header-file src="src/ios/Plugins/AppDelegate+MiPush.h" />
        <source-file src="src/ios/Plugins/AppDelegate+MiPush.m" />

        <header-file src="src/ios/lib/MiPushSDK.h" />
        <source-file src="src/ios/lib/libMiPushSDK.a" framework="true" />

        <framework src="UserNotifications.framework" weak="true" />
        <framework src="libresolv.dylib" weak="true" />
        <framework src="libxml2.dylib" weak="true" />
        <framework src="libz.dylib" weak="true" />
        <framework src="SystemConfiguration.framework" weak="true" />
        <framework src="MobileCoreServices.framework" weak="true" />
        <framework src="CFNetwork.framework" weak="true" />
        <framework src="CoreTelephony.framework" weak="true" />
    </platform>

    <platform name="android">
        <config-file target="config.xml" parent="/*">
            <feature name="MiPushPlugin">
                <param name="android-package" value="com.ct.cordova.mipush.MiPushPlugin"/>
            </feature>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/manifest">
            <uses-permission android:name="android.permission.INTERNET" />
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
            <uses-permission android:name="android.permission.READ_PHONE_STATE" />
            <uses-permission android:name="android.permission.GET_TASKS" />
            <uses-permission android:name="android.permission.VIBRATE"/>
            <permission android:name="${applicationId}.permission.MIPUSH_RECEIVE" android:protectionLevel="signature" />
            <!--这里com.xiaomi.mipushdemo改成app的包名-->
            <uses-permission android:name="${applicationId}.permission.MIPUSH_RECEIVE" />
            <!--这里com.xiaomi.mipushdemo改成app的包名-->
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <service
                android:enabled="true"
                android:process=":pushservice"
                android:name="com.xiaomi.push.service.XMPushService"/>
            <service
                android:name="com.xiaomi.push.service.XMJobService"
                android:enabled="true"
                android:exported="false"
                android:permission="android.permission.BIND_JOB_SERVICE"
                android:process=":pushservice" />
            <!--注：此service必须在3.0.1版本以后（包括3.0.1版本）加入-->
            <service
                android:enabled="true"
                android:exported="true"
                android:name="com.xiaomi.mipush.sdk.PushMessageHandler" />
            <service android:enabled="true"
                android:name="com.xiaomi.mipush.sdk.MessageHandleService" />
            <!--注：此service必须在2.2.5版本以后（包括2.2.5版本）加入-->
            <receiver
                android:exported="true"
                android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver" >
                <intent-filter>
                    <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                    <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </receiver>
            <receiver
                android:exported="false"
                android:process=":pushservice"
                android:name="com.xiaomi.push.service.receivers.PingReceiver" >
                <intent-filter>
                    <action android:name="com.xiaomi.push.PING_TIMER" />
                </intent-filter>
            </receiver>
            <receiver
                android:exported="true"
                android:name="com.ct.cordova.mipush.MiPushReceiver">
                <intent-filter>
                    <action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE" />
                </intent-filter>
                <intent-filter>
                    <action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED" />
                </intent-filter>
                <intent-filter>
                    <action android:name="com.xiaomi.mipush.ERROR" />
                </intent-filter>
            </receiver>
            <meta-data android:name="MiPushAppKey" android:value="$MI_PUSH_APP_KEYmipush"></meta-data>
            <meta-data android:name="MiPushAppId" android:value="$MI_PUSH_APP_IDmipush"></meta-data>
        </config-file>

        <source-file src="src/android/MiPush_SDK_Client_3_6_17.jar" target-dir="libs" />
        <source-file src="src/android/MiPushPlugin.java" target-dir="src/com/ct/cordova/mipush" />
        <source-file src="src/android/MiPushReceiver.java" target-dir="src/com/ct/cordova/mipush" />

    </platform>
</plugin>
