【问题标题】:Android - Scheduling Local Notifications on PhoneGap Build / Apache Cordova 4.1.1Android - 在 PhoneGap Build / Apache Cordova 4.1.1 上安排本地通知
【发布时间】:2017-01-16 08:42:42
【问题描述】:

我在尝试在 Android 应用上安排本地通知时遇到问题(使用 PhoneGap 构建)。

我正在尝试将本地通知安排在设定的日期和时间(例如 2016 年 9 月 23 日中午 12:00)。

我尝试过使用以下插件:

https://build.phonegap.com/plugins/2081

我的 config.xml 文件如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns   = "http://www.w3.org/ns/widgets"
    xmlns:gap   = "http://phonegap.com/ns/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id          = "****"
    versionCode = "292000" 
    version     = "2.9.2" >

    <gap:config-file platform="android" parent="/manifest">
 <application android:debuggable="true" />
</gap:config-file>

<!-- versionCode is optional and Android only -->

<name>****</name>

<description>
   ****
</description>

<author href="****" email="****">
    ****
</author>

<icon src="icon.png" />
<allow-navigation href="*" />
<access origin="*" />

<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="23"/>

<gap:plugin name='cordova-plugin-whitelist' source='npm' />

<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />

</widget>

然后我使用以下代码安排通知:

cordova.plugins.notification.local.schedule({
    title: $title,
    text: $message,
    at: $date
});

为最新的 PhoneGap 版本 (cli-6.3.0) 构建时,我在 build.phonegap.com 站点上收到以下错误:

错误 - 如果使用 PhoneGap >= 4.0.0,必须更新一些官方插件。请升级任何可能包含以下文件的插件版本:LocalNotification.java

似乎该插件尚未针对最新版本的 PhoneGap 进行更新,导致构建失败。

我已尝试为该插件的最新支持版本 (PhoneGap 3.7.0) 构建。构建成功完成,直接安装在 Android 设备上时,一切正常。通知按计划触发。

但是,当尝试将此构建提交到 Google Play 商店时,构建被拒绝并出现以下错误:

您的 APK 因包含违反恶意行为政策的安全漏洞而被拒绝。警报页面包含有关如何解决问题的更多信息。如果您提交了更新,您的应用的旧版本仍会在 Google Play 上发布。

该构建现在需要使用 Apache Cordova v4.1.1 才能被 Google Play 接受。

我环顾四周,但在任何地方都找不到解决方案。有没有人知道一个修复程序,或者另一个允许在支持 Apache Cordova v4.1.1 或更高版本的 Android 上安排本地通知的插件?

【问题讨论】:

  • @RaGu 在以下链接中查看基本的本地通知工作示例 - github.com/gandhirajan/Cordova_Local_Notification 希望它可以帮助您入门
  • 在以下链接中查看基本的本地通知工作示例 - github.com/gandhirajan/Cordova_Local_Notification 希望它可以帮助您入门

标签: android cordova notifications phonegap-build localnotification


【解决方案1】:

我自己修好了。

更改插件名称将起作用。

我们需要在 config.xml 中找到合适的插件并替换旧版本。

就我而言,我已经改变了

<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="pgb" />

<gap:plugin name="trunk.plugin.local-notification" /> 

【讨论】:

    【解决方案2】:

    改变

    <gap:plugin name='cordova-plugin-whitelist' source='npm' />
    
    <plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
    

    <plugin name='cordova-plugin-whitelist' source='npm' />
    
    <plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="npm" />
    

    【讨论】:

      猜你喜欢
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 2018-07-19
      • 1970-01-01
      • 2020-06-16
      相关资源
      最近更新 更多