0

I have recently started some app development with Telerik's AppBuilder and am running into one thing that I'm not certain of. I added a custom plugin to my project (Cordova Local Notifications Plugin) which seemed to work (it shows up in my solution now under a Plugins folder), but I have no idea how to reference the scripts and such from it. According to the Telerik documentation (Reference the Custom Plugin in index.html and config.xml), they say to add includes for anything with in the plugin.xml file, yet this plugin doesn't have that.

Any ideas on how I reference their script so I can start using it? Do I just reference Plugins/cordova-plugin-local-notifications-master/www/local-notification.js file direct or something else? Here is their plugin.xml file:

<?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="de.appplant.cordova.plugin.local-notification"
    version="0.8.0dev">

<name>LocalNotification</name>

<description>The purpose of the plugin is to create an platform independent javascript interface for Cordova based mobile applications to access the specific Notification API on each platform.</description>
<repo>https://github.com/katzer/cordova-plugin-local-notifications.git</repo>
<keywords>notification, local notification, alarm, scheduler, tile, live tiles, ios, android, windows phone 8, wp8</keywords>
<license>Apache 2.0</license>

<author>Sebastián Katzer</author>

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

<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device" />

<js-module src="www/local-notification.js" name="LocalNotification">
    <clobbers target="plugin.notification.local" />
</js-module>

<!-- ios -->
<platform name="ios">
    <config-file target="config.xml" parent="/*">
        <feature name="LocalNotification">
            <param name="ios-package" value="APPLocalNotification" onload="true" />
            <param name="onload" value="true" />
        </feature>
    </config-file>

    <header-file src="src/ios/APPLocalNotification.h" />
    <source-file src="src/ios/APPLocalNotification.m" />
</platform>

<!-- android -->
<platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="LocalNotification">
            <param name="android-package" value="de.appplant.cordova.plugin.localnotification.LocalNotification"/>
        </feature>
    </config-file>

    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <!--
         * The alarm receiver is triggered when a scheduled alarm is fired. This class
         * reads the information in the intent and displays this information in the
         * Android notification bar. The notification uses the default notification
         * sound and it vibrates the phone.
        -->
        <receiver android:name="de.appplant.cordova.plugin.localnotification.Receiver" />

        <!--
         * This class is triggered upon reboot of the device. It needs to re-register
         * the alarms with the AlarmManager since these alarms are lost in case of
         * reboot.
         -->
        <receiver android:name="de.appplant.cordova.plugin.localnotification.Restore" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <!--
         * The receiver activity is triggered when a notification is clicked by a user.
         * The activity calls the background callback and brings the launch inten
         * up to foreground.
        -->
        <activity android:name="de.appplant.cordova.plugin.localnotification.ReceiverActivity" android:launchMode="singleInstance" />
    </config-file>

    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    </config-file>

    <lib-file src="libs/android/android-support-v4.jar" />

    <source-file src="src/android/LocalNotification.java" target-dir="src/de/appplant/cordova/plugin/localnotification" />
    <source-file src="src/android/Receiver.java"          target-dir="src/de/appplant/cordova/plugin/localnotification" />
    <source-file src="src/android/Options.java"           target-dir="src/de/appplant/cordova/plugin/localnotification" />
    <source-file src="src/android/Restore.java"           target-dir="src/de/appplant/cordova/plugin/localnotification" />
    <source-file src="src/android/ReceiverActivity.java"  target-dir="src/de/appplant/cordova/plugin/localnotification" />
</platform>

<!-- wp8 -->
<platform name="wp8">
    <config-file target="config.xml" parent="/*">
        <feature name="LocalNotification">
            <param name="wp-package" value="LocalNotification"/>
        </feature>
    </config-file>

    <source-file src="src/wp8/LocalNotification.cs" />
    <source-file src="src/wp8/Options.cs" />
</platform>
</plugin>
Scott Salyer
  • 2,165
  • 7
  • 45
  • 82

1 Answers1

1

Any JavaScript file references are automatically inserted into your app when AppBuilder creates a build, so there is really not much you have to do aside from including the plugin. BTW, you should look for custom plugins first on the Verified Plugins Marketplace - which includes instructions on including the plugin in your AppBuilder project.

Rob Lauer
  • 3,075
  • 1
  • 32
  • 44
  • Thanks for the Verified Plugins Marketplace - had no idea that existed. I tried what you suggested (just adding the plugin to the project), but in the simulator I still get a JS error. I used an example from the Telerik site (`window.plugin.notification.local.add`), but it tells me "Cannot read property 'notification' of undefined" which I assume is because I didn't reference the JS file itself on index.html. I took their example further, but get errors that `window.plugin` is null so that's probably my first roadblock. Thoughts? – Scott Salyer Aug 12 '14 at 14:30
  • The AppBuilder simulator only supports core Cordova plugins (like filesystem) and doesn't support any custom plugins. That's why you should test custom plugins and physical devices - or even better - you can now use native emulators as well. – Rob Lauer Aug 12 '14 at 23:29
  • Yep, I saw that. The issue I'm finding is their demo gives me popups saying it doesn't support it (which is good), but when I try to implement it myself I can't even get that far. If I could figure out how to get the JS file(s) referenced in my index.html page, I think I'd be all set. – Scott Salyer Aug 13 '14 at 12:41
  • Just to be clear - are you having trouble in the simulator, using the AppBuilder Companion Apps, or on a physical device? Custom plugins won't work in the simulator or Companion Apps - only when deployed to a device directly (or when used in the native emulators). – Rob Lauer Aug 14 '14 at 17:29
  • It was the simulator first, but now the emulator is causing me trouble. That'll be a separate post on here though so thanks! – Scott Salyer Aug 19 '14 at 21:38