Open AwsmOli opened 7 years ago
@AwsmOli True, that's weird and maybe a Cordova applications issue. However, onNotificationClicked
is being invoked when you tap the notification, check updated logging on mentioned https://github.com/tsubik/ionic2-geofence repo.
I am seeing the same issue on Android 4.2.2, will test in iOS soon. I am not super-familiar with Android development, but as some random googling told me, there are several places to look:
i did some fairly random trial-and-error with flags on both intents, but no luck yet. any hints where to look first?
Guys I'm trying on Android 6.x and got it working by ensuring to initialize() the plugin as soon as the ionicPlatform is ready, so I basically added the initialization here:
app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services','ngCordova'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if (window.geofence) {
window.geofence.initialize().then(function() {
console.log("Successful initialization");
}, function(error) {
console.log("Error", error);
});
window.geofence.onNotificationClicked = function (notificationData) {
alert('App opened from Geo Notification!');
};
}
(......)
however I couldn't make it restore the previous angularJS' state, but at least is firing the onNotificationClicked event, and from there I can manage to address the user where I prefer.
good news: @Tempus35 seems to have found a solution to this and already made a pull request : #116.
the magic happens in GeoNotificationNotifier.java
The pull request addresses a lot of other things, and is discussed, so it is still open. But if you urgently need the feature, you can use @Tempus35 's branch or just the file.
Any update on this? We have the same problem.
Suspicious Behaviour When i get a Notification created using this plugin with
openAppOnClick: true
and the App is in background Cordova seems to destroy the App and start Bootstrapping again.Side effects As a result of this the
onNotificationClicked
Eventhandler will never be executed.Seen on: Nexus 5X running Android 7.1.1
Not tested on iOS yet!
Steps to reproduce:
openAppOnClick: true
flag to the Fixures so that{ id: "5", latitude: 40.7257093, longitude: -74.0032786, radius: 4000, transitionType: 3, notification: { text: "New York - SOHO"} },
becommes:{ id: "5", latitude: 40.7257093, longitude: -74.0032786, radius: 4000, transitionType: 3, notification: { text: "New York - SOHO", openAppOnClick: true } },
ionic run android --device
Further investigation:
Using Logcat i can see that there is some Intent to open the Main Activity, followed by an attempt to play a sound for the Notification. and after that you can see a
Cordova.onDestroy()
and later again aCordova.onCreate()
To me it looks like the App itself is not restarted, and the Cordova activity as brought into foreground again, but for some reason Cordova just bootstraps the whole app again. Also while Cordova is bootstrapping you wont see the splash screen, but just a white screen until the app is loaded.
Logcat output when i tab the notification:
Can anyone confirm this? Can anyone try that on iOS?
I really have no idea right now how to look into this further, if anyone has some ideas, ill look into it and try to fix it.