Rexios80 / polar

‎‎‎‎‎This is a Dart plugin wrapper for the Polar SDK on Android and iOS
https://pub.dev/packages/polar
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

Plugin Does Not find Device if Firebase onBackgroundMessage is initialized #3

Closed clockwork189 closed 2 years ago

clockwork189 commented 2 years ago

Hello,

I've essentially replicated this bug: https://github.com/PhilipsHue/flutter_reactive_ble/issues/195 in my project, but while just using the polar library and firebase.

This issue seems to just popup if I call: FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); and passing onBackgroundMessage as a top-level function.

My main function looks like below:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  try {
    await FirebaseUtils.init();
    // FirebaseMessaging.onBackgroundMessage(onBackgroundMessage);
    runApp(MyApp()); // MyApp is the example app code
  } catch (err) {
    developer.log("MAIN ERR: ", error: err);
    rethrow;
  }
}

Currently, I am getting around this issue by commenting out or rather not using the FirebaseMessaging.onBackgroundMessage(onBackgroundMessage); feature. However if I do un-comment it out, the app fails silently, i.e. when I call connect, it just searches for the device but does not result in a connection.

I am wondering if what remonh87 says here has something to do with it? https://github.com/PhilipsHue/flutter_reactive_ble/pull/200

Rexios80 commented 2 years ago

This plugin does not directly control the bluetooth connection. If you can prove it's my code causing the issue I'll look into it, but I feel like this is something that belongs in the official repo.

clockwork189 commented 2 years ago

Yeah you are right. If anything the issue is on the Flutterfire/FirebaseMessaging side. I'll dig in myself and see if I can figure out some workaround. Thanks for the insight.

Rexios80 commented 2 years ago

If you do figure out a fix for the Polar SDK please PR it over there so I can get it in here.