cordova-plugin-ibeacon icon indicating copy to clipboard operation
cordova-plugin-ibeacon copied to clipboard

Review Ionic Native Compatibility

Open dopry opened this issue 7 years ago • 8 comments

  1. Expected behavior and actual behavior.

Ionic Native should be in sync with our releases. The API may change when we migrate to TypeScript, and there may be some new features already in the project that have deviated from Ionic Native's typings and wrappers.

We should do a manual review for now, it would be interesting if there were a way to streamline or automate ionic native updated. We should document the process here so we can consider automating it late.

dopry avatar Jul 26 '18 17:07 dopry

On a related note, there is a problem with the ionic native plugin and ionic v4: https://github.com/ionic-team/ionic-native/issues/2631

I am working on a PR since this is critical path for us.

halindrome avatar Sep 18 '18 21:09 halindrome

Any news on this? Working on a project, and I'd love to NOT do two separate projects (iOS & Android).

elTigre9 avatar Feb 04 '19 22:02 elTigre9

Any news? or no more work on this plugin?

burbia avatar Jul 29 '20 14:07 burbia

This actually works fine in ionic. we use it all the time. The trick for me was to build a service for Bluetooth operations, and in that service put declare let cordova: any; near the top. Then the cordova global is exposed and you can create a local handle to the location manager like this.locationManager = cordova.locations.locationManager and just use this.locationManager as your handle to the library.

halindrome avatar Jul 29 '20 15:07 halindrome

Hi @halindrome, that trick isn't working for me, maybe I am doing something wrong. I have the same code than https://github.com/ionic-team/ionic-native/issues/2631. Have added declare let cordova: any; and changed const delegate = this.ibeacon.Delegate(); for const delegate = new cordova.plugins.locationManager.Delegate(); in home.page.ts but same problem, delegate is undefined

do you have some working example?

burbia avatar Jul 29 '20 16:07 burbia

Nothing I can publish - sorry, proprietary app.

First, I wouldn't set a const to delegate. I don't actually have a 'home.page.ts' in my app... but whatever your simple page is has a class that it is exporting, right? Inside that class do something simple like this:

locationManager: any;

constructor( .... 
) {
  this.locationManager = cordova.plugins.locationManager;
}

Now you have locationManager initialized as a handle to the plugin. Then wherever in your code you need to do your delegate thing do:

let delegate = new this.locationManager.Delegate();

Then use the delegate handle to set up your region and monitoring handlers. Finally, when you are done, do

this.locationManager.setDelegate(delegate);

To tell it to do its thing.

halindrome avatar Jul 29 '20 16:07 halindrome

No luck, I have exactly

import { Component } from '@angular/core';
declare let cordova: any;

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  
  locationManager: any;

  constructor() {
    this.locationManager = cordova.plugins.locationManager;
  }

  public test(){
    let delegate = this.locationManager.Delegate();
    console.log(delegate);
  }

}

but delegate is empty (locationManager is {"delegate":{}"}), I am missing something?

burbia avatar Jul 29 '20 17:07 burbia

Huh. Stupid question - did you remember to add the ibeacon module in your config.xml file?

ionic cordova plugin add cordova-plugin-ibeacon

Also, I assume you are building this for native use, since it doesn't work at all in the browser.

Finally, I see above you did NOT do what I said. Do create your delegate object you do:

let delegate = new this.locationManager.Delegate();

halindrome avatar Jul 29 '20 18:07 halindrome