Comments (32)
Hi @propertynoticed, I'm sorry but I stop developing with ionic and manage to do it in iOS Swift.
from cordova-plugin-ibeacon.
Here is what I did to get it working. Note, I needed to use the localnotification plugin as well to ensure that I could actually receive an event with the app closed. An alert() is not sufficient. You need to use a method that iOS provides for actually delivering a message to a user when an app is closed. Local notifications are a perfect method for this.
var createLocalNotification = function (message) {
window.plugin.notification.local.add({
title: 'iBeaconSpike1',
message: message
});
};
var delegate = new cordova.plugins.locationManager.Delegate().implement({
didDetermineStateForRegion: function (pluginResult) {
createLocalNotification('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
},
didStartMonitoringForRegion: function (pluginResult) {
createLocalNotification('didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
},
didRangeBeaconsInRegion: function (pluginResult) {
createLocalNotification('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
}
});
var uuid = 'MY UUID';
var identifier = 'JUST AN IDENTIFIER PASSED IN ON THE MESSAGE';
var minor = /* MY MAJOR */;
var major = /* MY MINOR */;
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor);
cordova.plugins.locationManager.setDelegate(delegate);
cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)
.fail(console.error)
.done();
from cordova-plugin-ibeacon.
@morrissinger, Thanks.
from cordova-plugin-ibeacon.
Thanks a lot, it really does work like that.
It's important to actually start monitoring the region again, even if the app is called because of an region change. Otherwise there won't be a event. Makes sense now.
from cordova-plugin-ibeacon.
Hi everyone,
first of all thank you for this plugin.
I'm having some problem with notification on iOS when the app is closed. I'm using Ionic (http://ionicframework.com/) for my app, I have implemented this plugin and it works fine when the app is launched or in background (even in Android) but when I kill the app no notification are displayed.
I'm using Parse.com as notification service, I tested the notification system and it works even if the app is killed, so the issue is with this plugin.
Is there something to setup to make these events trigger? something in the delegate or things like that?
Thanks in advice.
from cordova-plugin-ibeacon.
@gabrieleCiaravolo The examples in the read me and the ones posted in this thread should work.
Try cordova.plugins.locationManager.enableDebugNotifications()
for a better insight on what's happening in the native layer and post the code you are trying to use.
from cordova-plugin-ibeacon.
@morrissinger I would like to know this implementation will it waked up the app which is killed? Because I try. its only working in the foreground and background mode.
Please advise! Thx
from cordova-plugin-ibeacon.
I have gotten it working with the app closed, but at least one trick with
this was that if the app is closed, you are limited in terms of how to get
the app to notify you that you have entered or exited a region. I think the
ONLY way to do it is with local notifications. There isn't any way that you
can get entering a region to automatically open the app; but if you use
regioning to set a local notification, the app will open of the user slides
the local notification on the lock screen or taps "Okay" on the alert (if
the phone is not locked).
On Mon, Dec 15, 2014 at 4:37 PM jayhuang75 [email protected] wrote:
@morrissinger https://github.com/morrissinger I would like to know this
implementation will it waked up the app which is killed? Because I try. its
only working in the foreground and background mode.Please advise! Thx
—
Reply to this email directly or view it on GitHub
#53 (comment)
.
from cordova-plugin-ibeacon.
@morrissinger Thank you so much for your response. Something so weird, because I did used the local notification. But the problem is this notification never been fired when the app is closed.
My question :
- Did this line of code are enough to trigger the local notification when the app is closed?
cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)
.fail(console.error)
.done();
- Which delegate in your working example is trigger this when the app is closed?
var delegate = new cordova.plugins.locationManager.Delegate().implement({
didDetermineStateForRegion: function (pluginResult) {
createLocalNotification('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
},
didStartMonitoringForRegion: function (pluginResult) {
createLocalNotification('didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
},
didRangeBeaconsInRegion: function (pluginResult) {
createLocalNotification('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
}
});
Thank you so much! Really appreciate!
from cordova-plugin-ibeacon.
My delegate calls the createLocalNotification function for each of the region-monitoring events. The plugin took care of everything it needed to to register the delegate with the OS, so the OS could call it during a region-monitoring event.
from cordova-plugin-ibeacon.
@morrissinger Thank you so much! And yes, I do the exact the same thing and also follow the guide ask the permission for the iOS 8(because I running iOS 8 in my test device) but I close the application nothing is fired.
By the way, I using the estimote iBeacon.
@petermetz, Hey Petermetz, I know you close this issue. but did you have any idea about this? Because when the app in background or in foreground it works like a charms, but when close the application, nothing is fire.
And of course I ask user permission
cordova.plugins.locationManager.requestAlwaysAuthorization();
Thx guys
And It is a really good plugin!
from cordova-plugin-ibeacon.
@jayhuang75 you are probably doing everything properly. If you set notifyEntryStateOnDisplay = true in the new cordova.plugins.locationManager.BeaconRegion method then this will trigger monitoring and or ranging (if you are using local notifications) more frequently. Without this notifyEntryStateOnDisplay monitoring or ranging only will happen when you enter, exit or are inside a region and even with those events that could take sometime.
from cordova-plugin-ibeacon.
@tassuru Hey, thank you for you reply, basically the problem I have its when I close the app (I mean Kill the app). the iBeacon never trigger the fire and get my local notification.
And for my understanding. Did you mean I have to add this line of code
var uuid = 'xxxx';
var identifier = 'xxx';
var minor = xxx;
var major = xxx;
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor);
// Add code basic on the suggestion of tassuru, Am I need to add other delegate for this? Or any fire trigger action for this one?
beaconRegion.notifyEntryStateOnDisplay = true;
And for the take sometime. the problem is it never fired.
So weird. Am I missing something?
Thank you advance guys!
from cordova-plugin-ibeacon.
no you need to add it as a parameter to this ...
var uuid = 'xxxx';
var identifier = 'xxx';
var minor = xxx;
var major = xxx;
var notifyEntryStateOnDisplay = true;
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor, notifyEntryStateOnDisplay );
from cordova-plugin-ibeacon.
@rudy-tassuru
Thank you for your reply and really appreciate your time. But I still dont have luck to get it works.
Here is my code. The problem still remain, when I close (kill the app), the app can not wake up when my iPhone 4S in the zoom.
var delegate = new cordova.plugins.locationManager.Delegate();
delegate.didDetermineStateForRegion = function (pluginResult) {
console.log('>>>>>didDetermineStateForRegion INSIDE>>>>>');
createLocalNotification('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
};
delegate.didStartMonitoringForRegion = function (pluginResult) {
createLocalNotification('didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
};
delegate.didRangeBeaconsInRegion = function (pluginResult) {
console.log('>>>>>didRangeBeaconsInRegion>>>>>');
createLocalNotification('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
};
var uuid = 'xxxx';
var identifier = 'xxx';
var minor = xxx;
var major = xxx;
var notifyEntryStateOnDisplay = true;
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor, notifyEntryStateOnDisplay);
cordova.plugins.locationManager.setDelegate(delegate);
cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)
.fail(console.error)
.done();
cordova.plugins.locationManager.startRangingBeaconsInRegion(beaconRegion)
.fail(console.error)
.done();
Thank you so much for your help
from cordova-plugin-ibeacon.
is the 4s on iOS 8? If so you need the following...
cordova.plugins.locationManager.requestAlwaysAuthorization();
from cordova-plugin-ibeacon.
@rudy-tassuru YES I have this too!
THX
from cordova-plugin-ibeacon.
@rudy-tassuru
Here is my code, everything seems strength forward!
var createLocalNotification = function (message) {
$window.plugin.notification.local.hasPermission(function(granted) {
if(granted){
$window.plugin.notification.local.add({
id: "iBeaconPOC",
message: message,
autoCancel: true
});
}else{
$window.plugin.notification.local.promptForPermission();
}
});
};
// required in iOS 8+
cordova.plugins.locationManager.requestAlwaysAuthorization();
var delegate = new cordova.plugins.locationManager.Delegate();
delegate.didDetermineStateForRegion = function (pluginResult) {
console.log('>>>>>didDetermineStateForRegion INSIDE>>>>>');
createLocalNotification('[DOM] didDetermineStateForRegion: ' + JSON.stringify(pluginResult));
};
delegate.didStartMonitoringForRegion = function (pluginResult) {
createLocalNotification('didStartMonitoringForRegion:' + JSON.stringify(pluginResult));
};
delegate.didRangeBeaconsInRegion = function (pluginResult) {
console.log('>>>>>didRangeBeaconsInRegion>>>>>');
createLocalNotification('[DOM] didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult));
};
var uuid = 'xxx';
var identifier = 'xxx';
var minor = xxx;
var major = xxx;
var notifyEntryStateOnDisplay = true;
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor, notifyEntryStateOnDisplay);
cordova.plugins.locationManager.setDelegate(delegate);
cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)
.fail(console.error)
.done();
cordova.plugins.locationManager.startRangingBeaconsInRegion(beaconRegion)
.fail(console.error)
.done();
Every time I kill the app. I re-back to the zoom. nothing is trigger.
from cordova-plugin-ibeacon.
yah everything looks to be OK. I guess my only last thing I can suggest short of running your code and going through it locally is did you properly patch the local notification plugin? I know there is a bug in the 0.7 branch that you have to patch manually yourself. If you don't patch it your app will never send out any notifications and will usually crash
from cordova-plugin-ibeacon.
@rudy-tassuru, Yes I have the get the latest 0.7.6. Still try to find the solution! Anyway! thank you so much!
from cordova-plugin-ibeacon.
Yes I understand you got the latest 0.7.6 build did you patch that build though? The 0.7.6 build has a bug in it that does require you to manually patch it.
from cordova-plugin-ibeacon.
@rudy-tassuru
Really? Can you point it out? What bugs we are talking about? THX
from cordova-plugin-ibeacon.
You can refer this katzer/cordova-plugin-local-notifications#309
NSString* notId = [[notification.userInfo objectForKey:@"id"] stringValue];
And changed it to:
NSString* notId = [notification.userInfo objectForKey:@"id"];
from cordova-plugin-ibeacon.
Moreover, I am finding solution of background monitoring of ibeacon when app is killed.
I try notifyEntryStateOnDisplay and it work when app in background and then wake up phone by click "home" / "power" key.
Do anyone have idea to achieve this purpose?
Thanks!
from cordova-plugin-ibeacon.
@hkcity1111 Thank you for your reply, I have fix this before. So I think the problem is not here.
I fixed like this
NSString* notId = NULL;
if ([[notification.userInfo objectForKey:@"id"] isKindOfClass:[NSString class]] ) {
notId = [notification.userInfo objectForKey:@"id"];
} else {
notId = [[notification.userInfo objectForKey:@"id"] stringValue];
}
if ([notId isEqualToString:id]) {
return notification;
}
And for archiving the wake up killed app function. I still searching the solution. As far as I can find its. seems the iBeacon plugin will search the beacon, when I switch the bluetooth off and on, the small icon in the top of the statues bar seems is searching just for 5 seconds. And its not trigger the local notification.
So my assumption is the Local notification is not fire when the application is killed.
Any other thing your guys found at this point?
from cordova-plugin-ibeacon.
I search background geolocation plugin from christocracy and I install sample in my phone.
I kill the at night and I find that the app will wake up next morning if I go to office by train and show notification when I am moving.
Still studying whether it will work with ibeacon plugin
from cordova-plugin-ibeacon.
@hkcity1111 have you found a Solution?
from cordova-plugin-ibeacon.
Hi
How to make the app in android to detect beacon when the app is killed. I am using local notification when the app enters inside a region. But I have doubt that when app is killed from the background no js calls will be there in that case , then how can I schedule a notification to be aware that app is detecting beacon even after killing it.
from cordova-plugin-ibeacon.
@gabrieleCiaravolo I am trying and super struggling to implement beacon functionality using ionicframework. It would be great if you can share the sample code as i completely newbie to ionic and cordova world. Very much thanks in advance.
from cordova-plugin-ibeacon.
Ok. @gabrieleCiaravolo Is it advisable to do it in Cordova ? any thoughts or suggestions will be really appreciated.
from cordova-plugin-ibeacon.
any solution ?
from cordova-plugin-ibeacon.
Hi,
You found a solution ?
from cordova-plugin-ibeacon.
Related Issues (20)
- what is the identifier used for? looking at all the underlying code it isn't used for beacon recognizing. HOT 2
- when debug is enabled, where is it viewable or stored? HOT 1
- how do I build another version of this library? HOT 1
- using thru Ionic-Native with Capacitor on android , Uncaught (in promise) TypeError: e.beacon.stopRangingBeaconsInRegion is not a function HOT 1
- i expect to see duplicates of beacons where there are multiple, but only see one.. am I doing something wrong? HOT 2
- is there a way to get the mac address of the beacon? HOT 1
- Does this plugin support android 9 and greater ? HOT 7
- Read custom field
- No beacons are found in Andoid 11 smartphones HOT 1
- exitRegion configuration timeout request
- Error: Importing IBeacon which does not have a ɵmod property
- Question: How can I decrease advertising interval as ibeacon device in android and ios?
- Sometimes Beacons within the range are detected differently. HOT 1
- Major and minor with wrong values HOT 1
- Compatibility with Android 12 HOT 4
- Add support of Android 12 (Google API 31) HOT 21
- Use plugin on iOS16+, there's no beacons response from callback! What does can we do on iOS16+
- cordova-plugin-ibeacon not working starting android 11 HOT 7
- Dependency missing in build.gradle for org.altbeacon:android-beacon-library:2.16.1 HOT 4
- Missing dependicies
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-ibeacon.