kenjdavidson / react-native-bluetooth-classic

⚛ Bluetooth classic Android(Bluetooth)/IOS(ExternalAccessory) module for serial communication
https://kenjdavidson.github.io/react-native-bluetooth-classic
MIT License
250 stars 94 forks source link

Expo Config Plugin #124

Closed amitferman closed 3 years ago

amitferman commented 3 years ago

Mobile Device Environment iOS

Is your feature request related to a problem? Please describe. You can't develop on Expo out-of-the-box with react-native-bluetooth-classic since it doesn't have a Config Plugin to handle native configuration.

Describe the solution you'd like A Config Plugin would be a very useful addition to the library. It would also expand its use cases to Expo projects.

kenjdavidson commented 3 years ago

I can see your points, although I've never used Expo. The few times I have (probably my own issue) I've messed things up and had to just export the project anyhow.

It looks like there are a bunch of best practice expo dependencies that I don't particularly want in the library, to me it looks like creating a expo-bluetooth-classic project and maintaining it separately would be best? Keeping all the extra Expo related dependencies separate.

I'll have to do a little reading, and I definitely don't have time to look into this now.

I can't think of anything specific to this library that would need to be in there, so effectively any expo-bluetooth plugin that updated the correct PLIST items would work. You've googled around and none exist?

Can you think of any other configurations in this library that would need to be included in the plugin? Since you've obviously got way more experience than I, any thoughts would be appreciated.

amitferman commented 3 years ago

Thanks for the quick response. The issue (or interesting part) with config plugins is that they were released by Expo about 3 months ago, so many React Native libraries using native code require you to "eject" from Expo and move to pure React Native development to use them. Furthermore, config plugins are essential for using Expo in a project with custom native code, such as yours. This means that for people like me, who want to develop iOS apps on a Windows machine and therefore can't eject from Expo, config plugins might be important.

Though I have only recently started to use Expo and develop on iOS, I might try to create the plugin according to Expo docs since it doesn't seem too complicated and the Expo docs provide an example I could use. To confirm, these: `UISupportedExternalAccessoryProtocols

com.apple.m1 ` are the only pList items required for native configuration, correct? I will let you know if I get it working and if I do, the plugin might be a useful thing to link in your README. Thanks again
kenjdavidson commented 3 years ago

I was looking around and there is a plugin

https://www.npmjs.com/package/@config-plugins/react-native-ble-plx

which is part of the Pollidea BLE library. It looks like it has most of the configuration, so you could probably take most of the code from it, and then add in the <key>UISupportedExternalAccessoryProtocols</key> <array> <string>com.apple.m1</string> </array> as you've mentioned.

It looks like this guy has added a number of config plugins

https://www.npmjs.com/search?q=%40config-plugins

maybe reach out to him, or get him involved in something like @config-plugins/bluetooth-serial-mfi or something that makes sense and manages all the bluetooth settings for android and IOS.

amitferman commented 3 years ago

That's a great idea. I'll try that as well. Thanks for helping me out with this!

kenjdavidson commented 3 years ago

No problem, whatever gets more people working faster is cool with me!

I just don't have the time at this point to really take a deep dive into it - it looks like this won't ever work with the Expo Go app - based on comments in that one library README.

I'm not sure how I feel about things like Expo in the grand scheme of things, I'd have to take a look back at it now that that they've made it possible to use more functionality (specifically for IOS). So thanks for opening this!

amitferman commented 3 years ago

Though it won’t work on the Expo Go app, Expo offers an “Expo Development Client” service that lets you install a precompiled runtime with your custom native packages, such as this one. That’s what I’m trying to do and I’ve had some success with it. I think it’s pretty cool that Expo let’s you create your own versions of the Expo Go app by just installing the expo-dec-client npm package and building on the cloud, though it’s very new. According to my research, developing iOS on Windows is a rapidly expanding field of services and Expo tries to be an all-in-one solution to this.

Check out this Expo-sponsored video if your interested: https://m.youtube.com/watch?v=Iw8FAUftJFU It explains the functionality very well.


From: Ken Davidson @.> Sent: Wednesday, August 11, 2021 10:19:31 AM To: kenjdavidson/react-native-bluetooth-classic @.> Cc: amitferman @.>; Author @.> Subject: Re: [kenjdavidson/react-native-bluetooth-classic] Expo Config Plugin (#124)

No problem, whatever gets more people working faster is cool with me!

I just don't have the time at this point to really take a deep dive into it - it looks like this won't ever work with the Expo Go app - based on comments in that one library README.

I'm not sure how I feel about things like Expo in the grand scheme of things, I'd have to take a look back at it now that that they've made it possible to use more functionality (specifically for IOS). So thanks for opening this!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/kenjdavidson/react-native-bluetooth-classic/issues/124#issuecomment-897006870, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFS35YXRW5OQJLQVOVLRRRDT4KWKHANCNFSM5B5UCYRA.

amitferman commented 3 years ago

After looking back on this problem, I was able to find a solution and opened a pull request accordingly. I intended to add a small addition to the README.md for Expo Users but created the pull request a bit too soon. Either way, the implementation is complete.