cordova-plugin-geofence icon indicating copy to clipboard operation
cordova-plugin-geofence copied to clipboard

Compiling correctly but not working?

Open luigi37 opened this issue 5 years ago • 14 comments

Looks like the plugin compiles properly on Android but no notification. I'm using Android 8.0 on Samsung... anyone had success in compiling an app and making the geofence work?

luigi37 avatar Feb 28 '19 21:02 luigi37

It's working as intended, I suppose. Android 8 introduced new logic to notifications, and considering the last commit was 2 years ago, it's impossible that the author of this plugin could have accounted for that.

Starting in Android 8.0 (API level 26), all notifications must be assigned to a channel or it will not appear. By categorizing notifications into channels, users can disable specific notification channels for your app (instead of disabling all your notifications), and users can control the visual and auditory options for each channel—all from the Android system settings (figure 11). Users can also long-press a notification to change behaviors for the associated channel.

https://developer.android.com/guide/topics/ui/notifiers/notifications

Nikituh avatar Mar 04 '19 14:03 Nikituh

Hi, of course no criticism to the developer or the plugin in itself but fact is that as per today it seems there is no working geofence plugin. So... is there any fork working (also) on Android 8 or any workaround to make this one working?

luigi37 avatar Mar 04 '19 15:03 luigi37

I'm not sure, I stumbled upon this repository by accident and just thought I'd answer your question. There are 259 forks of this repository, one of them is bound to have accounted for notifications in Android 8. If not, you can make your own fork and fix it. It's relatively straight-forward:

https://developer.android.com/training/notify-user/channels

Nikituh avatar Mar 04 '19 15:03 Nikituh

I have a fork that builds on Android 8 but not sure if it sends the notification yet. First order was to get it building. https://github.com/3dtech/cordova-plugin-geofence

salarelv avatar Mar 05 '19 06:03 salarelv

Thanks. Do you want me to give your fork a try? BTW: with the main repository I noticed a weird behavior on Android simulator (Android 7), it only issues notifications if Google Maps is open...

luigi37 avatar Mar 05 '19 07:03 luigi37

Wouldn't hurt if somebody else tries out. I am currently fighting some other plugin and do not have time to test it myself.

salarelv avatar Mar 05 '19 07:03 salarelv

Ok: I was not sure if it was ready for testing. Now that you confirmed, I'm fine to test (likely tonight :-) ) Thanks!

luigi37 avatar Mar 05 '19 08:03 luigi37

Still not wroking.... is there any fork that compile and works properly on Android 8? Thanks

luigi37 avatar Mar 21 '19 13:03 luigi37

@luigi37 Try mine if you want to: https://github.com/gemigkaka/cordova-plugin-geofence It compiles and works with notifications for Android 8+. I haven't updated the documentation yet, but as you'll see in GeofencePlugin.java, there's also functionality to dismiss notifications.

gemigkaka avatar Mar 29 '19 10:03 gemigkaka

Thank you so much! I was sure someone else (with better developer skills than me :-) ) could have had the same need but I was almost loosing hope! I will give it a try in the weekend!

luigi37 avatar Mar 29 '19 10:03 luigi37

No problem :) Please tell if you find any issues.

gemigkaka avatar Mar 29 '19 11:03 gemigkaka

I'm getting this error: Error: /home/..................../platforms/android/gradlew: Command failed with exit code 1 Error output: 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. /home/l...................../platforms/android/src/com/cowbell/cordova/geofence/GeofencePlugin.java:33: error: diamond operator is not supported in -source 1.6 private static HashMap<String, Long> snoozedFences = new HashMap<>(); ^ (use -source 7 or higher to enable diamond operator) /home/.............platforms/android/src/com/cowbell/cordova/geofence/TransitionJobService.java:31: error: lambda expressions are not supported in -source 1.6 Thread thread = new Thread(() -> { ^ (use -source 8 or higher to enable lambda expressions) /home......./platforms/android/src/com/cowbell/cordova/geofence/ReceiveTransitionsReceiver.java:65: error: diamond operator is not supported in -source 1.6 List<GeoNotification> geoNotifications = new ArrayList<>(); ^ (use -source 7 or higher to enable diamond operator) /home.........platforms/android/src/com/cowbell/cordova/geofence/RemoveGeofenceCommand.java:28: error: lambda expressions are not supported in -source 1.6 .addOnSuccessListener((Void aVoid) -> ^ (use -source 8 or higher to enable lambda expressions) 4 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I'm using

**cordova --version 7.1.0

cordova platform Installed platforms: android 6.3.0 ios 4.5.5**

luigi37 avatar Mar 31 '19 17:03 luigi37

It sounds like you're missing JDK 8 or the JAVA_HOME variable. Since cordova-android 6.3.0 JDK 8 is required. Check here: https://cordova.apache.org/docs/en/latest/guide/platforms/android/#installing-the-requirements (go to Installing the Requirements > Java Development Kit (JDK))

gemigkaka avatar Apr 01 '19 12:04 gemigkaka

In effect I have: java --version openjdk 10.0.2 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

And javac -version javac 1.8.0_191

would that work?

luigi37 avatar Apr 02 '19 18:04 luigi37