cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
265 stars 317 forks source link

Compiling correctly but not working? #291

Open luigi37 opened 5 years ago

luigi37 commented 5 years ago

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?

Nikituh commented 5 years ago

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

luigi37 commented 5 years ago

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?

Nikituh commented 5 years ago

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

salarelv commented 5 years ago

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

luigi37 commented 5 years ago

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...

salarelv commented 5 years ago

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

luigi37 commented 5 years ago

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

luigi37 commented 5 years ago

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

gemigkaka commented 5 years ago

@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.

luigi37 commented 5 years ago

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!

gemigkaka commented 5 years ago

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

luigi37 commented 5 years ago

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 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.

I'm using

**cordova --version 7.1.0

cordova platform Installed platforms: android 6.3.0 ios 4.5.5**

gemigkaka commented 5 years ago

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))

luigi37 commented 5 years ago

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?