flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

Cannot check for permissions in background using background_fetch

Open mootw opened this issue 4 years ago • 2 comments

🔙 Regression

Plugin no longer works in the background.

Old (and correct) behavior

I was able to check for permissions in the background using background_fetch.

Current behavior

It crashes with this stack trace:

04-19 13:05:32.195 18500 18500 D permissions_handler: Activity cannot be null. 04-19 13:05:32.338 18500 19258 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Android activity is required to check for permissions and cannot be null., null) 04-19 13:05:32.338 18500 19258 E flutter : #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) 04-19 13:05:32.338 18500 19258 E flutter : #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18) 04-19 13:05:32.338 18500 19258 E flutter : <asynchronous suspension> 04-19 13:05:32.338 18500 19258 E flutter : #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12) 04-19 13:05:32.338 18500 19258 E flutter : #3 MethodChannelPermissionHandler.checkPermissionStatus (package:permission_handler_platform_interface/src/method_channel/method_channel_permission_handler.dart:15:41) 04-19 13:05:32.338 18500 19258 E flutter : #4 PermissionActions.status (package:permission_handler/permission_handler.dart:25:51) 04-19 13:05:32.338 18500 19258 E flutter : #5 PermissionCheckShortcuts.isGranted (package:permission_handler/permission_handler.dart:54:33)

Reproduction steps

Use background_fetch plugin to generate a background fetch and check for permissions. The app has to be force closed for the error to occur. Not just in the background. The activity needs to be null.

Configuration

Version: 4.4.0+hotfix.4 --> 5.0.0+hotfix.3

Platform:

  • [X] :iphone: iOS (I do not have a stack trace for iOS but the background functions were not working there either).
  • [X] :robot: Android

mootw avatar Apr 19 '20 18:04 mootw

I had the same issue.

payam-zahedi avatar Dec 19 '20 18:12 payam-zahedi

My comment here might be helpful:

https://github.com/Baseflow/flutter-permission-handler/issues/334#issuecomment-815920393

nmfisher avatar Apr 08 '21 15:04 nmfisher

I'm seeing the same issue. @nmfisher 's comment identifies the problem well enough, but the details of the fix are well beyond me. Any ideas on how to work around this would be welcome.

tomkcook avatar Dec 05 '22 16:12 tomkcook

@mootw,

I suppose this issue is not relevant anymore, Else, please send us some minimal reproducible code or an example project where the error occurs.

Kind regards,

TimHoogstrate avatar Aug 24 '23 06:08 TimHoogstrate

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] avatar Sep 07 '23 09:09 github-actions[bot]