bndkt / react-native-widget-extension

Add widgets and live activities to a React Native app
https://bndkt.com/blog/2023/ios-live-activities
437 stars 33 forks source link

Lowering the minimum deployment version #2

Closed fobos531 closed 1 year ago

fobos531 commented 1 year ago

Hey, just found this repo, looks great and will definitely follow it!

I noticed that you support both the regular widgets and Live Activities. However, for Live Activities only iOS 16.x is supported. I was wondering, if you want to support only regular widgets, could we lower the minimum deployment version to 14.0, and just throw exceptions in the Native module if the live activities methods are being invoked on iOS <16.x?

EDIT: I see in the code that all the live activities methods are already wrapped in if available, which means that it should work just fine if we use the minimum deployment version of 14.0?

nandorojo commented 1 year ago

Better yet – don't throw an exception. Simply check if it's available from Swift (as you mentioned) and set the deployment target to 14

nandorojo commented 1 year ago

Opened a PR #4

bndkt commented 1 year ago

Hi @fobos531 and @nandorojo,

thanks for the patience, it took me a while to get to work on this again. It turns out you need to do more hedging against lower deployment targets than I did in the Swift code before, that's why it didn't work with deployment targets < 16.2 and I had to leave this in. I have now made the deployment target configurable and documented in the Readme how to guard this in the Swift files. I left the default at 16.2, because then it works without being too careful in the Swift file. If you want to support iOS versions < 16.2, you can change the deploymentTarget config option of the plugin and make your Swift code for the widgets safe for this. Hope this is useful for you!