flutter_background_fetch icon indicating copy to clipboard operation
flutter_background_fetch copied to clipboard

Added configurable requiresExternalPower and requiresNetworkConnectivity params

Open radiKal07 opened this issue 6 years ago • 11 comments

Added support to configure this params, fixing this issue: https://github.com/transistorsoft/transistor-background-fetch/issues/6

I am not familiar with Objective-C or the way to build a .framework and I am not sure what's with the _CodeResources folder, so please review these thoughtfully.

radiKal07 avatar Mar 17 '20 13:03 radiKal07

Not bad.

christocracy avatar Mar 17 '20 13:03 christocracy

Using my version via git dependency I get the following error: missing required architecture arm64 in file. So I think I messed up something regarding the way I built the .framework. Looking into it, as I said I am not familiar with Obj-C packages.

radiKal07 avatar Mar 17 '20 14:03 radiKal07

Ok, fixed the issue but now _CodeSignature folder got deleted, not sure if this is an issue

radiKal07 avatar Mar 17 '20 14:03 radiKal07

Sorry, I can't accept this PR as-is. The plugin already has existing config options requiresCharging and requiredNetworkType (used by Android) which can be applied for iOS.

christocracy avatar Mar 17 '20 15:03 christocracy

Also, you're sending null values to the native iOS side from toMapwhen those values are not provided.

{
  stopOnTerminate: false, 
  enableHeadless: true, 
  forceAlarmManager: true, 
  requiresExternalPower: null, 
  requiresNetworkConnectivity: null
}

Which crashes iOS.

'NSInvalidArgumentException', reason: '-[NSNull boolValue]: unrecognized selector sent to instance 0x7fff80618070'

christocracy avatar Mar 17 '20 15:03 christocracy

@christocracy I think we can re-use requiresCharging param but nor sure about requiredNetworkType since it's an enum on Android and a bool on iOS. Do you think NetworkType.NONE should be false on iOS and anything else true? I would rather separate them because someone can get confused. For example someone may use NetworkType.CELLULAR thinking it would work on iOS also but the job will get executed even if there is wifi. What do you think?

Btw, regarding the second comment I initialise the variables to false, so that happens only if user explicitly passes null which is weird but I will provide a fix to treat that case also.

radiKal07 avatar Mar 18 '20 06:03 radiKal07

@christocracy I pushed new commit where I re-use the requiresCharging param for iOS and fixed the requiresNetworkConnectivity: null crash. Still not sure about requiredNetworkType enum vs requiresNetworkConnectivity bool

radiKal07 avatar Mar 18 '20 07:03 radiKal07

@christocracy any updates on this?

radiKal07 avatar Mar 31 '20 07:03 radiKal07

@christocracy ping

radiKal07 avatar Jun 04 '20 05:06 radiKal07

@christocracy The implementation of this feature would be very helpful.

proninyaroslav avatar Aug 09 '20 20:08 proninyaroslav

@christocracy fixed conflicts

radiKal07 avatar Aug 25 '20 11:08 radiKal07