Skip to content

Not able to do network call #28

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

Closed
anchal-td opened this issue Nov 23, 2021 · 1 comment
Closed

Not able to do network call #28

anchal-td opened this issue Nov 23, 2021 · 1 comment

Comments

@anchal-td
Copy link

anchal-td commented Nov 23, 2021

I need to upload a file in foreground service & when I am doing the request but didn't receive the response.

 final videoPath = await FlutterForegroundTask.getData<String>(key: 'videoPath');
    print('customDataVideo: $videoPath'); // works till here
    var request = http.MultipartRequest('POST', Uri.parse(url);
   print('customData 2: 2');  // no getting this log
@Dev-hwang
Copy link
Owner

Try setting the allowWifiLock option as shown below to true. And make sure the app has internet permission.

  Future<void> _initForegroundTask() async {
    await FlutterForegroundTask.init(
      androidNotificationOptions: const AndroidNotificationOptions(
        channelId: 'notification_channel_id',
        channelName: 'Foreground Notification',
        channelDescription: 'This notification appears when the foreground service is running.',
        channelImportance: NotificationChannelImportance.LOW,
        priority: NotificationPriority.LOW,
      ),
      iosNotificationOptions: const IOSNotificationOptions(),
      foregroundTaskOptions: const ForegroundTaskOptions(
        autoRunOnBoot: true,
        allowWifiLock: true,
      ),
      printDevLog: true,
    );
  }

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

No branches or pull requests

2 participants