Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

methodChannel in invokeMethodOnUiThread(Map) is null #114

Closed
boymustafa opened this issue Sep 7, 2022 · 2 comments · Fixed by #236
Closed

methodChannel in invokeMethodOnUiThread(Map) is null #114

boymustafa opened this issue Sep 7, 2022 · 2 comments · Fixed by #236
Assignees

Comments

@boymustafa
Copy link

Hi Clevertap team,
We are having issue where Clevertap SDK is clashing with the Work Manager library (https://pub.dev/packages/workmanager). The issue is when we execute await Workmanager().cancelAll()
setCleverTapInAppNotificationButtonClickedHandler and setCleverTapInboxNotificationButtonClickedHandler wont be executed. Even the Clevertap is throwing an error

D/CleverTapPlugin(29108): methodChannel in invokeMethodOnUiThread(Map) is null

We also tried to change to another work manager library which is here https://pub.dev/packages/background_fetch and the result is still the same. Is there any way from your side to help us with this issue? Your feedback and help on this matter are much appreciated.

@william-ct
Copy link
Contributor

Hi @boymustafa Can you help us as figure out whats your use case for using WorkManager library. Also if possible can you share the code snippet where you've used await Workmanager().cancelAll(). Also can you provide us with the below details of the SDK's you're using:-

  • WorkManager library version
  • CleverTap flutter plugin version

@boymustafa
Copy link
Author

Hi,
We use WorkManager to update our app widget (https://developer.android.com/develop/ui/views/appwidgets/overview ) in the background.
This is the method we call the cancel all method and then register the task:

void startBackgroundUpdate() async {
    await Workmanager().cancelAll();
    if (Platform.isAndroid) {
      Workmanager().registerPeriodicTask(
        '3',
        'updatePrayerTimeWidget',
        // existingWorkPolicy: ExistingWorkPolicy.keep,
      );
    } else {
      Workmanager().registerOneOffTask(
        iosTaskKey,
        iosTaskKey,
        initialDelay: const Duration(minutes: 15),
      );
    }
  }

The startBackgroundUpdate method is called inside the main method.

Future<void> main() async {
  final PrayerTimeHomeWidget _prayerTimeHomeWidget = PrayerTimeHomeWidget();
  WidgetsFlutterBinding.ensureInitialized();

  Workmanager().initialize(callbackDispatcher, isInDebugMode: kDebugMode);
  _prayerTimeHomeWidget.startBackgroundUpdate();

.... do the rest of things

}

As for the details of the SDK:

  1. WorkManager library version
    We are using the forked version of the workManager which is here
    workmanager:
    git:
    url: https://github.com/sunalwaysknows/flutter_workmanager
    ref: f37742bcf612c51e9571d623138a21a90a5992ea
    The reason why we are using the forked version instead of the community version is this issue Flutter workmanager not working in ios background fluttercommunity/flutter_workmanager#402 which also exist for background_fetch library here [BUG] Background fetch is not working on release app while running in iPhone transistorsoft/flutter_background_fetch#285 (comment) .

  2. CleverTap flutter plugin version
    clevertap_plugin: 1.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants