Git Product home page Git Product logo

Comments (32)

gabrieleCiaravolo avatar gabrieleCiaravolo commented on June 5, 2024 1

Hi @propertynoticed, I'm sorry but I stop developing with ionic and manage to do it in iOS Swift.

from cordova-plugin-ibeacon.

morrissinger avatar morrissinger commented on June 5, 2024

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.

Ranjan-2014 avatar Ranjan-2014 commented on June 5, 2024

@morrissinger, Thanks.

from cordova-plugin-ibeacon.

maheee avatar maheee commented on June 5, 2024

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.

gabrieleCiaravolo avatar gabrieleCiaravolo commented on June 5, 2024

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.

petermetz avatar petermetz commented on June 5, 2024

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

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

morrissinger avatar morrissinger commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

  1. 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();
  1. 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.

morrissinger avatar morrissinger commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

tassuru avatar tassuru commented on June 5, 2024

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

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

rudy-tassuru avatar rudy-tassuru commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

rudy-tassuru avatar rudy-tassuru commented on June 5, 2024

is the 4s on iOS 8? If so you need the following...
cordova.plugins.locationManager.requestAlwaysAuthorization();

from cordova-plugin-ibeacon.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

@rudy-tassuru YES I have this too!
THX

from cordova-plugin-ibeacon.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

rudy-tassuru avatar rudy-tassuru commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

rudy-tassuru avatar rudy-tassuru commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

@rudy-tassuru
Really? Can you point it out? What bugs we are talking about? THX

from cordova-plugin-ibeacon.

hkcity1111 avatar hkcity1111 commented on June 5, 2024

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.

hkcity1111 avatar hkcity1111 commented on June 5, 2024

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.

jayhuang75 avatar jayhuang75 commented on June 5, 2024

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

hkcity1111 avatar hkcity1111 commented on June 5, 2024

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.

sunsus avatar sunsus commented on June 5, 2024

@hkcity1111 have you found a Solution?

from cordova-plugin-ibeacon.

kapilkumarchawala avatar kapilkumarchawala commented on June 5, 2024

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.

codestorycooked avatar codestorycooked commented on June 5, 2024

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

codestorycooked avatar codestorycooked commented on June 5, 2024

Ok. @gabrieleCiaravolo Is it advisable to do it in Cordova ? any thoughts or suggestions will be really appreciated.

from cordova-plugin-ibeacon.

semirturgay avatar semirturgay commented on June 5, 2024

any solution ?

from cordova-plugin-ibeacon.

medrockstar avatar medrockstar commented on June 5, 2024

Hi,

You found a solution ?

from cordova-plugin-ibeacon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.