Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support local notifications #743

Closed
cookieguru opened this issue Jan 24, 2016 · 25 comments
Closed

Support local notifications #743

cookieguru opened this issue Jan 24, 2016 · 25 comments

Comments

@cookieguru
Copy link
Contributor

There are many Cordova plugins showing notifications, and most are designed for receiving push notifications. I've found only one is designed for locally-generated notifications: cordova-plugin-local-notifications. This also appears to be the only plugin that supports ongoing notifications.

When adding the plugin (version 1.0.0) to config.xml the build fails at the following step:

...
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugResources
:generateDebugSources
:compileDebugJava/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/de/appplant/cordova/plugin/localnotification/LocalNotification.java:564: error: cannot find symbol
                    webView.evaluateJavascript(js, null);
                           ^
  symbol:   method evaluateJavascript(String,)
  location: variable webView of type CordovaWebView
/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/de/appplant/cordova/plugin/localnotification/LocalNotification.java:561: error: cannot find symbol
        webView.post(new Runnable(){
               ^
  symbol:   method post()
  location: variable webView of type CordovaWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 3.721 secs
/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/home/travis/.nvm/v0.10.36/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)
Warning: Command failed: Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/home/travis/.nvm/v0.10.36/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)
� Use --force to continue.
Aborted due to warnings.
travis_time:end:050b0570:start=1453667958600688729,finish=1453668037390511551,duration=78789822822

The command "grunt build deploy" exited with 6.
Done. Your build exited with 1.

There's also cordova-plugin-local-notifications-pgb which fixes some of the issues this plugin has with PhoneGap build, but it fails with the following:

...
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugResources
:generateDebugSources
:compileDebugJavaNote: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 3.721 secs
/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/home/travis/.nvm/v0.10.36/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)
Warning: Command failed: Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/src/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/annotation/AttrRes.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
Error: /home/travis/build/eclipsesource/tabris-js-build-template/build/platforms/android/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone (/home/travis/.nvm/v0.10.36/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)
� Use --force to continue.
Aborted due to warnings.
travis_time:end:050b0570:start=1453667958600688729,finish=1453668037390511551,duration=78789822822

The command "grunt build deploy" exited with 6.
Done. Your build exited with 1.
@mpost
Copy link
Member

mpost commented Jan 25, 2016

Apparently there is a problem with this plugin on Cordova 5 katzer/cordova-plugin-local-notifications#426

Do you build against tabris.js nightly? We have migrated to Cordova 5.0.0 for the upcoming Tabris.js 1.6 release.

@cookieguru
Copy link
Contributor Author

@mpost I had been building against 1.5

@mpost
Copy link
Member

mpost commented Jan 26, 2016

I would like to think that the error is on their side. Could you try against Tabris.js nightly, although that shouldn't have too much impact.

@cookieguru
Copy link
Contributor Author

Finally got a passing build. Will play around with this tomorrow to see if everything is working.

In case anyone else is interested:

<plugin name="https://github.com/C895/cordova-plugin-local-notifications.git" />

@cookieguru
Copy link
Contributor Author

Also, this built successfully against both 1.5.0 and nightly. Have only tested Android so far.

@mpost
Copy link
Member

mpost commented Jan 27, 2016

Good to hear. :)

@cookieguru
Copy link
Contributor Author

Fails on app launch.

TypeError: Cannot redefine property: device
TypeError: Cannot redefine property: device
    at Function.defineProperty (native)
    at Object.utils.defineGetterSetter (./cordova.js:1759:16)
    at clobber (./cordova.js:531:15)
    at Object.assignOrWrapInDeprecateGetter (./cordova.js:546:9)
    at Object.exports.mapModules (./cordova.js:1465:21)
    at ./cordova.js:1255:18
    at f (./cordova.js:693:33)
    at Channel.fire (./cordova.js:821:23)
    at ./cordova.js:1247:32
    at onScriptLoadingComplete (./cordova.js:1667:5)
deviceready has not fired after 5 seconds.
Channel not fired: onCordovaReady
Channel not fired: onCordovaInfoReady

@mpost
Copy link
Member

mpost commented Jan 28, 2016

Okay, we would have to investigate what kind of environment the plugin requires.

@awaitingimage
Copy link

Hi, we are currently assessing whether to use TabrisJS instead of just cordova for our next app build. We will require the use of local notifications. Has this issue progressed any further as I was getting similar issues when trying to use this cordova plugin.

Or are there any other ways of triggering local notifications using TabrisJS?

@ralfstx
Copy link
Member

ralfstx commented Feb 16, 2016

I've opened #785 for the problem with the cordova device plugin. Chances are that the local-notifications plugin works when this issue is fixed.

@ralfstx
Copy link
Member

ralfstx commented Feb 16, 2016

@mpost Could you try again?

@cookieguru
Copy link
Contributor Author

@ralfstx When will #785 be in the Tabris.js nightly build? I just built an app and see the same error.

@ralfstx
Copy link
Member

ralfstx commented Feb 16, 2016

@cookieguru the nightly build should pick up the change. Please try again tomorrow.

@cookieguru
Copy link
Contributor Author

Now seeing this error on startup:

Could not load tabris module: TypeError: Cannot read property 'get' of undefined
TypeError: Cannot read property 'get' of undefined
    at d.extend._nativeGet (./node_modules/tabris/tabris.min.js:32:16343)
    at f (./node_modules/tabris/tabris.min.js:32:4515)
    at tabris.Properties.get (./node_modules/tabris/tabris.min.js:32:13211)
    at Function.tabris._publishDeviceProperties (./node_modules/tabris/tabris.min.js:33:9376)
    at ./node_modules/tabris/tabris.min.js:33:9465
    at ./node_modules/tabris/tabris.min.js:33:9498
    at ./node_modules/tabris/tabris.min.js:34:15245
    at Object.defineProperty.get (<anonymous>:1:1401)
    at Object.i.require (<anonymous>:1:1570)
    at Object.tabris._start (<anonymous>:1:2695)

In this case _nativeGet is referring to Proxy's _nativeGet.

@mpost
Copy link
Member

mpost commented Feb 17, 2016

I can confirm the error reported by @cookieguru

@ralfstx
Copy link
Member

ralfstx commented Feb 17, 2016

May bad, sorry! Working on a fix right now.

@mpost
Copy link
Member

mpost commented Feb 17, 2016

@cookieguru @elfazzo In general we can confirm that the plugin works. We are still having some problems with the device object that is required internally. We are currently working on a fix.

The screenshot below shows the plugin in action:

screenshot_20160217-152504

@mpost
Copy link
Member

mpost commented Feb 18, 2016

@cookieguru @elfazzo We have remedied the problem with the device in the latest nightly. You should now be able to use the notification plugin as advertised.

Please let us know if you have any more problems.

@awaitingimage
Copy link

@mpost Thanks, will be trying this in the next few days. Will let you know if there are any issues.

@cookieguru
Copy link
Contributor Author

@mpost I still see this error on launch when building with nightly using de.appplant.cordova.plugin.local-notification@0.8.4.

@mpost
Copy link
Member

mpost commented Feb 19, 2016

@cookieguru this error is two steps back... are you certain you build against nightly?

@mpost
Copy link
Member

mpost commented Feb 19, 2016

@cookieguru I can confirm your reported error. Apparently the build service is not yet in sync with our changes. I'll report when it is working properly.

@mpost
Copy link
Member

mpost commented Feb 19, 2016

@cookieguru The build service has configuration problem when building a debug build and selecting "nightly". It does not make use of the nightly builds. In fact it builds against what is given in your package.json dependencies. Therefore you can currently enforce to use nightly by specifying it explicitly in the package.json:

  "dependencies": {
    "tabris": "https://tabrisjs.com/downloads/nightly/tabris.tgz"
  }

@cookieguru cookieguru changed the title Ongoing notifications Support local notifications Feb 20, 2016
@cookieguru
Copy link
Contributor Author

Using the above instructions to build against nightly with de.appplant.cordova.plugin.local-notification@0.8.4 works great. Have only tested Android so far.

Using this omnibus script everything works except loading icons from remote URLs. Did not test locally loaded icons, however I did notice that the app locally caches the remote icons.

@jumpjack
Copy link

any working "hello world" example showing how to use cordova plugins, and specifically notifications plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants