question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unhandled promise rejection

See original GitHub issue

Version

Tell us which versions you are using:

  • react-native-ble-manager v_latest as of 4thAug2017

  • react-native react-native-cli: 2.0.1 react-native: 0.47.0

  • iOS/Android v.Android 7.1.1

I have linked ble-manager library using react-native link. I followed the instructions to change minSDK version to 18.

I am getting the following Warning when I use

"BleManager.start({showAlert: false, allowDuplicates: false});"

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'start' of undefined
TypeError: Cannot read property 'start' of undefined

I have traced the problem to the bleManager.start call in the following function in BleManager.js.

start(options) {
    return new Promise((fulfill, reject) => {
      if (options == null) {
        options = {};
      }
      console.log("Start BLE")
      bleManager.start(options, (error) => {
        if (error) {
          reject(error);
        } else {
          fulfill();
        }
      });
    });
  }

I am not sure what went wrong or how to fix it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
virdesaicommented, Aug 11, 2017

For RN 0.47, change

public BleManagerPackage() {}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
	List<NativeModule> modules = new ArrayList<>();

	modules.add(new BleManager(reactApplicationContext));
	return  modules;
}

@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
	return new ArrayList<>();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
	return Collections.emptyList();
}

to

public BleManagerPackage() {}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
	List<NativeModule> modules = new ArrayList<>();

	modules.add(new BleManager(reactApplicationContext));
	return  modules;
}

public List<Class<? extends JavaScriptModule>> createJSModules() {
	return new ArrayList<>();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
	return Collections.emptyList();
}
1reaction
marcosinigagliacommented, Aug 4, 2017

Try with RN 0.46, I don’t know if there are breaking changes in 0.47

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is an unhandled promise rejection? - Stack Overflow
A rejected promise is like an exception that bubbles up towards the application entry point and causes the root error handler to produce...
Read more >
Tracking Unhandled Promise Rejections - TrackJS
When a promise is rejected, it looks for a rejection handler. If it finds one, like in the example above, it calls the...
Read more >
Handling those unhandled promise rejections with JS async ...
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was ......
Read more >
What is UnhandledPromiseRejectionWarning
The Promise.reject() method returns a Promise object that is rejected with a given reason. The unhandledrejection event is sent to the global scope...
Read more >
Window: unhandledrejection event - Web APIs | MDN
The unhandledrejection event is sent to the global scope of a script when a JavaScript Promise that has no rejection handler is rejected; ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found