在IBM工作灯使用katzer本地通知 [英] Using katzer local notification in IBM Worklight

查看:136
本文介绍了在IBM工作灯使用katzer本地通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用这个插件科尔多瓦在 https://github.com/katzer/科尔多瓦 - 插件和本地通知

I want to use this cordova plugin at https://github.com/katzer/cordova-plugin-local-notifications

如何去与我现有的IBM工作灯项目,使这个插件?我曾尝试各种方法将其整合,没有任何结果。

How to go about integrating this plugin with my existing IBM Worklight project? I have trying various methods to integrate it without any result.

我目前收到此错误的logcat的:

I am getting this error currently from the logcat:

02-24 11:15:03.035: D/CordovaLog(2439): file:///data/data/com.iCareApp/files/www/default/index.html: Line 17 : Uncaught TypeError: Cannot read property 'notification' of undefined

或者有其他更简单的替代品,以完成这件事?基本上我想能​​够调度本地通知该设备在特定时间上从存储在我的申请中的数据

Or is there any other easier alternatives to get this done? Basically i want to be able to schedule local notification on the device at specific times from the data stored in my application

推荐答案

我得到这个按照下面的工作。

I got this to work by following the below.

演示项目: https://www.dropbox.com/s/58urdluauc8u3l1/AndroidLocalNotifications .ZIP

由于工作灯不支持科尔多瓦的Plugman轻松安装科尔多瓦V3插件,一些体力劳动才能得到这一切建立正确的...... blachs。

Because Worklight does not support Cordova's Plugman to easily "install" Cordova v3 plug-ins, some manual labor is required to get it all set-up properly... blachs.

要注意AppName,它被用来在整个过程中的插件声明。如果你在你的应用程序中使用一个不同的名称,你需要与你的更新相应的值。

Note the appName , it is used throughout the process for plug-in declarations. If you use a different name for in your app, you will need to update the values accordingly with yours.

  1. 注意 nativeResources 文件夹,在那里我已经放在我编辑的文件:

  1. Pay attention to the nativeResources folder, where I've placed the files I edited:

  • 在AndroidManifest.xml中:
    • 在这我添加了所需的权限,接收器,活动
    • AndroidManifest.xml:
      • In it I added the required permission, receivers, activities
      • 包含必需的.jar文件的插件
      • 包含插件的Java类
      • 在他们我已经编辑插件进口报关
      • 包含config.xml文件;看到底部的插件功能的声明

      • Contains config.xml; see at the bottom for the plug-in feature declaration

      • 插件的JavaScript实现在头部引用元素
        <脚本SRC =JS /本地notification.js>< / SCRIPT>

      在main.js:

      function wlCommonInit(){
          window.plugin.notification.local.add({ message: 'this is a local notification' });
      }
      

      以上会后,应用程序的启动立即发送一个本地通知。
      在插件的主页你可以阅读更多有关可能的通知选项。

      The above will send a local notification immediately after the application's launch.
      In the plug-in's homepage you can read more about the possible notification options.

      在本地notification.js:

      In local-notification.js:

      • 添加顶部:
        cordova.define(LocalNotification功能(需,出口,模块){

      • 添加底部:
        });

      • Add at the top:
        cordova.define("LocalNotification", function(require, exports, module) {

      • Add at the bottom:
        });

      在生成的Andr​​oid项目\资产\ WWW \默认\ JS \工作灯\ cordova_plugins.js,地址:

      In the generated Android project\assets\www\default\js\worklight\cordova_plugins.js, add:

      ,
      {
          "file": "../js/local-notification.js",
          "id": "LocalNotification",
          "clobbers": [
              "plugin.notification.local"
          ] 
      } 
      

      需要注意的是重新构建工作灯项目将覆盖此文件,因此你的变化,它会消失......你需要重复每一个构建之后这一步。

      Note that re-building the Worklight project will overwrite this file, and thus your changes in it will be gone... you'll need to repeat this step after every build.

      没有,我能找到preserve修改工作灯工作室之间的文件好方法的基础之上。

      There is no good way that I could find to preserve changes to this file between Worklight Studio builds.

      这篇关于在IBM工作灯使用katzer本地通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆