Creating a Cordova Plugin for Garmin Mobile SDK

760 views Asked by At

I'm mainly a hybrid application developer that uses Cordova. I've run into an interesting scenario where I think that I'll need to create a Cordova Plugin to implement the native Garmin SDK for iOS and Android available here.

I've reviewed cordova's plugin documentation and have completed their example. Link here. I've also reviewed a number of decent resources on the matter see Instabug's and one from Modus.

However, I lack sufficient knowledge to understand why some components are missing from the Garmin SDK that are included in other tutorials. Mainly the ConnectIQ.bundle.

I'm also unsure as to what could be causing the errors I'm experiencing. I have a feeling that the project cannot find the specific files that implement the ConnectIQ.framework via the custom plugin I'm attempting to develop.

I even found another person's implementation unofficial cordova Connect IQ plugin they released last year. Upon execution, this is my error log:

2016-12-18 18:35:04.748 appTest[56419:4257397] CDVPlugin class CIQPlugin (pluginName: connectiq) does not exist.
2016-12-18 18:35:04.748 appTest[56419:4257397] [CDVTimer][connectiq] 0.180006ms
2016-12-18 18:35:13.942 appTest[56419:4257397] CDVPlugin class CIQPlugin (pluginName: ConnectIQ) does not exist.
2016-12-18 18:35:13.942 appTest[56419:4257397] ERROR: Plugin 'ConnectIQ' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2016-12-18 18:35:13.942 app Test[56419:4257397] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["INVALID","ConnectIQ","initializeWithUrlScheme",["prefs-123456"]]

This contains the contents of the plugin.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2014 PayPal. All rights reserved. -->
<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="com.heavydutydev.cordova.ciq"
    version="0.0.1">
    <name>Cordova CIQ</name>
    <description>This plugin allows basic interactions with the Garmin Connect IQ native interfaces</description>
    <keywords>garmin, connect-iq, connect iq</keywords>
    <license>NONE</license>
    <engines>
            <engine name="cordova" version="&gt;=5.0.0" />
    </engines>




    <!-- ios -->
    <platform name="ios">
        <js-module src="www/cdv-plugin-connect-iq.js" name="ConnectIQ">
         <clobbers target="ConnectIQ" />
        </js-module>
        <config-file target="config.xml" parent="/*">
            <feature name="ConnectIQ">
                <param name="ios-package" value="CIQPlugin" onload="true" />
            </feature>
        </config-file>
        <source-file src="src/ios/ConnectIQ.framework" framework="true" />
    <!--    <header-file src="src/ios/PayPalMobileCordovaPlugin.h" />
        <source-file src="src/ios/PayPalMobileCordovaPlugin.m" />

        <header-file src="src/ios/PayPalMobile/PayPalConfiguration.h" />
        <header-file src="src/ios/PayPalMobile/PayPalFuturePaymentViewController.h" />
        <header-file src="src/ios/PayPalMobile/PayPalMobile.h" />
        <header-file src="src/ios/PayPalMobile/PayPalOAuthScopes.h" />
        <header-file src="src/ios/PayPalMobile/PayPalPayment.h" />
        <header-file src="src/ios/PayPalMobile/PayPalPaymentViewController.h" />
        <header-file src="src/ios/PayPalMobile/PayPalProfileSharingViewController.h" />

        <source-file src="src/ios/PayPalMobile/libPayPalMobile.a" framework="true" />
        <source-file src="src/ios/PayPalMobile/libCardIO.a" framework="true" />
        <source-file src="src/ios/PayPalMobile/libopencv_core.a" framework="true" />
        <source-file src="src/ios/PayPalMobile/libopencv_imgproc.a" framework="true" />


        <framework src="Accelerate.framework" />
        <framework src="AudioToolbox.framework" />
        <framework src="AVFoundation.framework" />
        <framework src="CFNetwork.framework" />
        <framework src="CoreGraphics.framework" />
        <framework src="CoreLocation.framework" weak="true" />
        <framework src="CoreMedia.framework" weak="true" />
        <framework src="CoreVideo.framework"/>
        <framework src="MessageUI.framework" />
        <framework src="OpenGLES.framework" />
        <framework src="MobileCoreServices.framework" />
        <framework src="Security.framework" />
        <framework src="SafariServices.framework"/>
        <framework src="SystemConfiguration.framework" />
        <framework src="QuartzCore.framework"/>
        <framework src="UIKit.framework"/>


        <framework src="libc++.dylib" />
        <framework src="libPayPalMobile.a" />
        <framework src="libCardIO.a" />
        <framework src="libopencv_core.a" />
        <framework src="libopencv_imgproc.a" /> -->

    </platform> 

    <platform name="android">
        <js-module src="www/cdv-plugin-connect-iq.js" name="ConnectIQ">
        <clobbers target="ConnectIQ" />
        </js-module>
        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="ConnectIQ">
                <param name="android-package" value="com.heavydutydev.cordova.ciq.CIQPlugin" />
            </feature>
        </config-file>

        <source-file src="src/android/com/heavydutydev/cordova/ciq/CIQPlugin.java" target-dir="src/com/heavydutydev/cordova/ciq" />
        <source-file src="src/android/com/heavydutydev/cordova/ciq/CIQContext.java" target-dir="src/com/heavydutydev/cordova/ciq" />
        <source-file src="src/android/libs/connectiq.jar" target-dir="libs" />
<!-- 
        <config-file target="AndroidManifest.xml" parent="/manifest">
            <uses-permission android:name="android.permission.CAMERA" />
            <uses-permission android:name="android.permission.VIBRATE" />

            <uses-feature android:name="android.hardware.camera" android:required="false" />
            <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
            <uses-permission android:name="android.permission.INTERNET"/>
        </config-file> -->

<!--         <config-file target="AndroidManifest.xml" parent="/manifest/application">
            <service android:name="com.paypal.android.sdk.payments.PayPalService"
            android:exported="false" />
            <activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
            <activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
            <activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
            <activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
            <activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
            <activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
            <activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
            <activity android:name="com.paypal.android.sdk.payments.PayPalProfileSharingActivity" />
            <activity android:name="com.paypal.android.sdk.payments.ProfileSharingConsentActivity" />
            <activity
                android:name="io.card.payment.CardIOActivity"
                android:configChanges="keyboardHidden|orientation" />
            <activity android:name="io.card.payment.DataEntryActivity" />
        </config-file> -->

    </platform>

</plugin>

Based on these errors and my research, I think that the plugin.xml and the config.xml are not properly aligned with the SDK I'm trying to implement. If anyone can provide some additional troubleshooting steps so that I may learn more about the problem it would be greatly appreciated.

1

There are 1 answers

1
Maxim On

I have started my own plugin inspiring by ddteeter plugin.
But it will support only Android operating system.

As I understand you got some errors using ConnectIQ Сordova plugin.
So I recommend you to do the following from scratch:

1) Download/clone ddteeter plugin from github.
2) Create cordova project. Add Android platform.
3) Install plugman utility using NPM.
4) Install ddteeter plugin into your just created project.

call plugman install --platform android --project platforms\android --plugin some\filesystem\path\to\ddteeter\plugin\root\directory

After that you will be able to connect to your device (or Monkey C application if it is necessary).
Also even for direct messaging you will have to install Garmin Connect application from Google Play overwise Android BLE SDK will not work.

Also keep in mind this plugin does not contain any valuable logic. But it allows you to enumerate paired devices to check that all works. This plugin exposes 'ConnectIQ' global variable accessible from your JavaScript code.