<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:rim="http://www.blackberry.com/ns/widgets"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="cordova-plugin-nuance-speechkit"
    version="2.0.1">
    <name>Nuance SpeechKit</name>
    <description>Cordova Nuance SpeechKit Plugin</description>
    <license>Apache 2.0</license>
    <keywords>cordova,nuance,speechkit,tts</keywords>

    <preference name="URL" default="" />
    <preference name="APP_KEY" default="" />

    <js-module src="www/speechkit.js" name="speechkit">
        <clobbers target="speechkit" />
    </js-module>

    <engines>
        <engine name="cordova" version=">=6.2.0" />
    </engines>
    <!-- android -->
    <platform name="android">
        <framework src="com.nuance:speechkit:2.1+@aar" />

        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="speechkit" >
                <param name="android-package" value="ee.codehouse.SpeechKit"/>
            </feature>
        </config-file>
        <config-file target="res/values/strings.xml" parent="/resources">
            <string name="sk_url">$URL</string>
            <string name="sk_app_key">$APP_KEY</string>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/*">
            <uses-permission android:name="android.permission.RECORD_AUDIO" />
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.INTERNET"/>
        </config-file>


        <source-file src="src/android/SpeechKit.java" target-dir="src/ee/codehouse" />
    </platform>

    <!-- ios -->
    <platform name="ios">
        <dependency id="cordova-plugin-cocoapod-support"/>

        <pod id="SpeechKit" />
        <config-file target="config.xml" parent="/*">
            <feature name="speechkit">
                <param name="ios-package" value="CDVSpeechKit"/>
            </feature>
        </config-file>
        <config-file target="*-Info.plist" parent="sk_url">
            <string>$URL</string>
        </config-file>
        <config-file target="*-Info.plist" parent="sk_app_key">
            <string>$APP_KEY</string>
        </config-file>
        <config-file target="*-Info.plist" parent="NSMicrophoneUsageDescription">
            <string>Required for speech recognition</string>
        </config-file>

        <header-file src="src/ios/CDVSpeechKit.h" />
        <source-file src="src/ios/CDVSpeechKit.m" />
    </platform>
</plugin>
