umair13adil / simple_beacons_flutter

A flutter plugin project to range & monitor iBeacons.
Apache License 2.0
35 stars 42 forks source link

version 1.0.16 - setMethodCallHandler is never been called #22

Open daveleenew opened 4 years ago

daveleenew commented 4 years ago

version 1.0.16 - setMethodCallHandler is never been called.

never been called

EricHier commented 3 years ago

I've got the same problem - did you find a solution?

In my testing, I found out that the method is called when I move the app to the background. When entering it again, the beacon scanner stops monitoring again.

dhachayawat commented 3 years ago

Me too, I found same problem on some android device, but ios no problem.

jallynme commented 3 years ago

version 1.0.20 - setMethodCallHandler is never been called too. but for iOS is working fine.

baranacikgoz commented 2 years ago

Same problem. Any solution?

barangungor commented 2 years ago

@baranacikgoz which platform do you use?

baranacikgoz commented 2 years ago

@baranacikgoz which platform do you use?

` if (Platform.isAndroid) {

  //Prominent disclosure
  await BeaconsPlugin.setDisclosureDialogMessage(
      title: "Need Location Permission",
      message: "This app collects location data to work with beacons.");

  //Only in case, you want the dialog to be shown again. By Default, dialog will never be shown if permissions are granted.
  await BeaconsPlugin.clearDisclosureDialogShowFlag(false);
}

BeaconsPlugin.channel.setMethodCallHandler((call) async {
    if (call.method == 'isPermissionDialogShown') {
      //Do something here
    }
});

`

solved by writing this code

barangungor commented 2 years ago

My code used to work like this, but it doesn't work now because it never run the setMethodCallHandler function. @umair13adil maybe you can look that.

    print('HELLO');
    if (Platform.isAndroid) {
      //Prominent disclosure
      print('HELLO ANDROID');
      await BeaconsPlugin.setDisclosureDialogMessage(
              title: "Arka Plan İzni",
              message:
                  "MyMessage")
          .then((value) {
        print('HELLO ANDROID 2');
      });
      await BeaconsPlugin.clearDisclosureDialogShowFlag(false);
      BeaconsPlugin.channel.setMethodCallHandler((call) async {
        print("Method: ${call.method}");
        if (call.method == 'scannerReady') {
          await BeaconsPlugin.startMonitoring();
        }
      });
    } else if (Platform.isIOS) {
      await BeaconsPlugin.startMonitoring();
    }

and that's my prints

I/flutter (22731): HELLO I/flutter (22731): HELLO ANDROID I/flutter (22731): HELLO ANDROID 2