Cannot read property 'locationManager' with iBeacon sample code

Asked 1 years ago, Updated 1 years ago, 57 views

I downloaded cordova-plugin-ibeacon to try iBeacon samples in Monaca Cloud IDE and imported it in Monaca's Manage cordova Plugins

So far, I have been referring to the following Asial BLOG.
http://blog.asial.co.jp/1343

After installing and running on Galaxy S4 (Android 4.4.2), the iBeacon sample page shows icons from 1 to 6, but the Monaca console displays an error similar to the following, and it seems that iBeacon is not recognized.

CreateBeacon error:TypeError:Cannot read property 'locationManager' of undefined
Delete error:TypeError:Cannot read property 'locationManager' of undefined

Beacon is available from Aplix, which is correctly recognized by the sample app provided by the company, and is able to display and range the radio intensity.

Monaca iBeacon Sample Page
http://docs.monaca.mobi/cur/ja/sampleapp/samples/ibeacon/

The codeova-plugin-ibeacon appears to have been deployed correctly below the plugins folder in the Monaca cloud IDE, but the sample article does not have such an image/description that it has been deployed and configured correctly.
I didn't mess with the sample code.

I don't think there's enough information to make the app recognize cordova-plugin-ibeacon, but I couldn't find it even after searching the internet for a day.

Many iBeacon-enabled apps have been developed for iOS, but
Will the sample code not work on Android?

monaca ibeacon

2022-09-30 20:23

2 Answers

Thank you for your reply.

Below are the points you have pointed out.

□Did you paste the code as it is?
As we are using the sample project as it is, overall coding defects are
It shouldn't be there.
The onDeviceReady you mentioned is defined as a callback function on the coding.

□ Reference Site Information
https://github.com/petermetz/cordova-plugin-ibeacon/issues/110
I was watching because it was a hit in the search.
I think this resolution was originally due to an error that should have been "onDeviceReady" but "onDeviceReady()" and worked properly by correcting it...

Same as above,
CreateBeacon error:TypeError:Cannot read property 'locationManager' of undefined
Delete error:TypeError:Cannot read property 'locationManager' of undefined
I imagine that if the code is not interpreted correctly even a little bit, I might get an unpredictable error like this.

*In the English version of stackoverflow, the catch balls of the respondents and the questioner are divided accordingly, but in the Japanese version, I was not sure how to post the questioner, so I am using the answer field.
Maybe they will identify the questioner.

Thank you for your cooperation.


2022-09-30 20:23

I found an example where I encountered the same error and it was resolved after proper device ready.

https://github.com/petermetz/cordova-plugin-ibeacon/issues/110

I understand that you referred to http://blog.asial.co.jp/1343, but did you paste the code as it is?

Be DeviceReady before running.

It says, but is there no problem with this?

I forgot about the sample project.Indeed, it is written in the device ready.

https://github.com/monaca/project-templates/blob/4.1_cordova/24-ibeacon/www/js/app.js#L35

If the code is not interpreted correctly even for a moment, I might get an error like this that I can't guess.

In the case of Issue mentioned above, we intend to pass the function onDeviceReady, but we passed the result of running onDeviceReady() on the spot, so the action we wanted to do at device ready was done immediately, resulting in a runtime error.Translating the error directly means that cordova.plugins was undefined (the value when referring to undefined properties) because "Undefined 'locationManager' property" cannot be read.

So I suspected that I was running without waiting for deviceready in the same way as this, but otherwise I might not be able to load the plug-in.


2022-09-30 20:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.