Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Does it work with Expo? #53

Open
leodevbro opened this issue Jul 2, 2023 · 13 comments
Open

Does it work with Expo? #53

leodevbro opened this issue Jul 2, 2023 · 13 comments

Comments

@leodevbro
Copy link

I mean, should I start a new RN project using Expo or using RN CLI? As far as I know, Expo has some limitations of accessing device modules like Camera, Bluetooth.

@yusufipsum
Copy link

I guess first the config plugin should be created for that... https://docs.expo.dev/config-plugins/plugins-and-mods/

Because the same case exists react-native-ble-plx library. In order to use the library on expo, we need to add a config plugin in app.json file like this:

Ekran Resmi 2023-09-03 15 23 23

@JoseOliveira-sensefinity

Hey, did you figure how to make it run on expo? @leodevbro
Thanks

@leodevbro
Copy link
Author

did you figure how to make it run on expo?

Here is another conversation about it:
#21

Unfortunately it seems we have no progress on it.

@jole141
Copy link

jole141 commented Nov 3, 2023

@JoseOliveira-sensefinity @leodevbro It works for me but with an additional EAS setup and build
https://docs.expo.dev/build/setup/

In my project, I've already had EAS setup so It worked, but I didn't try to use it only with a simple Expo project...

In some cases, certain modules or libraries may not be compatible with Expo or may not be supported within the Expo environment. When facing these limitations, "EAS Build" can be a valuable tool to address these issues.

@yusufipsum
Copy link

@JoseOliveira-sensefinity @leodevbro It works for me but with an additional EAS setup and build https://docs.expo.dev/build/setup/

In my project, I've already had EAS setup so It worked, but I didn't try to use it only with a simple Expo project...

In some cases, certain modules or libraries may not be compatible with Expo or may not be supported within the Expo environment. When facing these limitations, "EAS Build" can be a valuable tool to address these issues.

Hi @jole141, How did you? i use bare workflow too but didn't work, doesn't this require an expo module? Can you share the steps with us?

@jole141
Copy link

jole141 commented Nov 10, 2023

@yusufipsum Oh sorry, I've just realized that I started this thread but in the end I've used "react-native-ble-advertise": "^0.4.0",
https://github.com/barakataboujreich/react-native-ble-advertise

Usage example (somewhere in my RN code):

const startBeaconAdvertising = useCallback(
    async (uuid: string, major: string, minor: string) => {
      try {
        console.log('[BEACON] - demo started');
        await setCompanyId(parseInt(COMPANY_ID, 16) as any);
        setIsBeaconBroadcasting(true);
        await broadcast(uuid, parseInt(major, 16) as any, parseInt(minor, 16) as any);
        console.log('[BEACON] - Beacon broadcasting started');
      } catch (error) {
        console.log('[BEACON] - Beacon broadcasting error', error);
        setIsBeaconBroadcasting(false);
      }
    },
    [stopBeaconAdvertising]
  );

This library has some "type" problems but with parseInt(major, 16) as any you can do a small workaround.

I don't have time right now, but I'll try to setup a simple Expo project with an EAS build to do a project example.

@jole141
Copy link

jole141 commented Nov 23, 2023

I have created a simple Expo tutorial:
https://github.com/jole141/expo-examples/tree/react-native-ble-advertise

@leodevbro
Copy link
Author

@jole141, Dear Josip, even if this tutorial will turn out to be not fully successful, I still strongly appreciate your effort and your kindness to help us. For sure I am going to try your tutorial very soon.

@leodevbro
Copy link
Author

One question: so, the react-native-ble-advertise library has broadcast feature, but does not have scan feature, right? It would be unfortunate, because I need both.

@barakataboujreich
Copy link

barakataboujreich commented Nov 23, 2023

One question: so, the react-native-ble-advertise library has broadcast feature, but does not have scan feature, right? It would be unfortunate, because I need both.

@leodevbro hello, i am the author of react-native-ble-advertise

no the library doesn't have a ble scanning functionality since i use react-native-ble-manager for ble scanning, and created react-native-ble-advertise for missing functionality in our app.

prior to today i did not know that you can use BLE with Expo, i thought it was only possible through RN CLI. now thanks to @jole141 tutorial, i was able to use both react-native-ble-advertise and react-native-ble-manager in expo

if you are interested i can create a example using both libraries

@leodevbro
Copy link
Author

if you are interested i can create a example using both libraries

@barakataboujreich, Oh, sure, that would be super I think. I will be super thankful.

@barakataboujreich
Copy link

barakataboujreich commented Nov 23, 2023

@barakataboujreich, Oh, sure, that would be super I think. I will be super thankful.

@leodevbro you can find the tutorial here expo-ble-scan-advertise-example

@leodevbro
Copy link
Author

Thanks, I'll check it out and do some experiments with it 🚀🚀🚀🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants