android - 试图让 phonegap 的 Android LocalNotification 插件在 cordova-1.6.0 中工作

标签 android plugins cordova localnotification

我正在尝试将使用 Android 的 LocalNotification 插件的 phonegap-1.4.1 项目升级到 cordova-1.6.0

我在这里找到了这个链接:https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/109 它说,对于 Android:使用 CordovaInterface 对象的 this.ctx.getContext() 方法获取 Conext 对象。

我编辑了 LocalNotification.java 并通过更改以下行使我的项目编译无误:

来自:

alarm = new AlarmHelper(this.ctx);
...
final SharedPreferences alarmSettings = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE);
...
final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
...
final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
...
final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();

收件人:

alarm = new AlarmHelper(this.ctx.getContext());
...
final SharedPreferences alarmSettings = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE);
...
final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
...
final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
...
final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();

但是我必须承认,我真的不知道自己在做什么,通知不起作用,我在应用程序日志中也没有收到任何错误 :(

还刚刚注意到,根据我的 onDeviceReady() 函数中的示例,我有以下内容:

console.log("Device ready");

if (typeof plugins !== "undefined") {
   plugins.localNotification.add({
      date : new Date(),
      message : "Phonegap - Local Notification\r\nSubtitle comes after linebreak",
      ticker : "This is a sample ticker text",
      repeatDaily : false,
      id : 4
   });
}

如果我删除了 if 条件 typeof plugins !== "undefined"然后我在我的应用程序日志中得到一个错误:Uncaught ReferenceError: plugins is not defined

我想在 cordova 中还有其他变化。如果某处有将 android 插件升级到 cordova 的指南,如果有用的话。

最佳答案

今天升级到 Cordova-1.6.1,现在可以用了 ;)

勇敢地承认这可能是“椅子/键盘”界面问题。 想想当我升级到 1.6.0 时忘记在我的 index.html 的标题中更改它

关于android - 试图让 phonegap 的 Android LocalNotification 插件在 cordova-1.6.0 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10218745/

相关文章:

ios - Cordova 无法从 CLI 构建,但从 XCode xcworkspace 构建可以完美运行

android - 2019年如何在Android原生应用中添加Power BI报表

android - 是否可以从 Android Wear SDK 获取 GPS 位置?

java - 为什么我的plugin.yml 没有加载?布基特

inheritance - 如何任意扩展 "object"

android - 创建未命名为 HelloWorld 的 phonegap 项目

java - 将数据从 Activity 传递到 SurfaceView

android - 从 native Android 相机应用程序捕获黑白照片

c# - 从使用 Activator.CreateInstance(type) 创建的实例中捕获异常

iphone - openDatabase() 方法抛出异常(SECURITY_ERR : DOM Exception 18)