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
Execute code on enter/exit fence? #35
Comments
Only by |
There must be a way to get a customization action to execute when a geofence event happens though? Natively this can happen on both iOS and Android as far as I know. |
I issued a pull request that was merged a few days ago that allows this for iOS. It uses NotificationCenter to send a message to anyone who is registered to listen to it. Check it out, there are details on how to implement it (Objective-c code only, but Swift shouldn't be too hard to figure out): #43 I'll be working on Android support for this in a little while. |
This is already do-able with this plugin (at least on iOS, haven't started working on Android yet). |
I have tested it on Android and it seems to work aswell without native code |
@frmi Can you post your code? It isn't working form me. Also, the problem is not that it doesn't work at all but it doesn't work when your app is in background (for android). |
@razagill i'm sorry, i was wrong this does not work if the app is forcefully closed, since the webview will be null. |
@razagill "since the webview will be null" - is that the reason on Android ? When the app was forcefully closed, iOS re-opens the app on a geofence event and therefore recreates the webview . |
@johnrobertcobbold Not exactly, you can't run javascript code in the background on android. So you have to modify the plugin and add new class that extends the BroadcastReceiver (details are on the main page of this plugin), I was able to catch the transitions in the background after this modification. |
So basically like iOS using the new wkWebView... oh great :-/ |
@razagill @johnrobertcobbold The plugin is still alive even if you forcefully kill the app. The notification is successfully tiggered, but the onTransitionReceived callback cannot be executed since the cordova web view has been released by closing the app. I guess there is no way around the broadcast receiver for now. |
their must be a method to call a custom url scheme, rather than setting up a notification, it seems like you have to setup everything you need to when you create the fence and the system takes over. maybe use it in conjunction with https://github.com/EddyVerbruggen/Custom-URL-scheme |
Is it possible to run some code when a user enters or exists a fence? For example I want to call a REST method which lets the server know what has happened. This can then be used for really cool things such as sending a push message to the user, etc etc.
For example:
The text was updated successfully, but these errors were encountered: