alexkendall / react-native-bluetooth-cross-platform

Cross-Platform Bluetooth & WiFi React Native Module. Powered by underdark http://underdark.io/.
179 stars 35 forks source link

Unique AppId for each app #14

Open virl opened 7 years ago

virl commented 7 years ago

Hello! One of the users told me that in React bindings it is impossible to set AppId during configuration — although in native libraries it is possible.

Unique AppId allows discovery and communication to be isolated and non-interfering between different apps from different developers that use same library.

Emilios1995 commented 7 years ago

I've added this feature in iOS. Will do it in Android later and submit a PR.

virl commented 7 years ago

@Emilios1995 Great!

azanli commented 6 years ago

@Emilios1995 Can you please share your code for doing that? I want to be able to essentially allow NetworkManager to assign a custom string to User{} so that that one-time message can be shared between Android and iOS devices without needing to connect. This unique AppId would be the perfect vehicle for driving that string across platforms that have difficulty connecting.

virl commented 6 years ago

@Progoogler What do you mean by AppId? In library the purpose of AppId is to isolate different apps (of different vendors) from communication with each other with incompatible application-level protocols.

azanli commented 6 years ago

@virl I assumed that AppId would be a unique identifier set by calling a function on NativeManager such as setAppId('AppName') but instead I would use it for the purpose of setting some unique string that would be meaningful only to my application. For example, at the moment I'm modifying some things under the hood in the library so that User.Name is set as the name of the user instead of the device. (User provided their own name in this instance.)

EDIT: Nevermind, I looked around a bit more closely and saw that byte[] frameData isn't constructed within the library, it's something default within the device itself. Do you think it would be possible to change the frameData that is broadcast by the device, meaning appending or changing the values of Peer or User{} as detected by other devices?

virl commented 6 years ago

@Progoogler I’m the author of underlying native library.

frameData is just packet that is sent in device-to-device connection and can have arbitrary contents.

Underlying library have no notion of users, only connections. You can implement users abstraction on top of that, if you need. Don’t know why you want to change the library/bindings for that, unless bindings prevent you from sending packets to connections with other devices (which I doubt the case).

On native level, it is not possible to send arbitrary string during peer discovery without establishing connection, because BLE packets that is used for discovery have max size of only 20 bytes (with even less free space).

azanli commented 6 years ago

@viri I noticed you carried some clout from viewing other issues but I kept getting confused by that notion because you're not assigned a contributor or collaborator title. XD

You're right, I don't need to change anything for sending user abstractions because sendMessage() can sufficiently take care of that upon establishing connection ('Detected peer') regardless of inviting or accepting invitation from another device. Thank you for pointing these things out, I'm so excited to start integrating this library into my app now.

Excellent work by the way. For the past few days I've been so let down by the fact that Android and iPhone cannot communicate via Bluetooth, NFC, etc. Then recently I discovered Google Nearby but the RN bridge isn't mature enough yet. And then I discovered you guys, I'm super happy! Thank you.

virl commented 6 years ago

@Progoogler I don’t have contributor title in this project because currently I have no relation to it other than the fact that this is community-driven react project that uses my library that is by itself proprietary commercial product (but with free binary version). But I’m happy to explain any details related to the work of underlying library.

For the past few days I've been so let down by the fact that Android and iPhone cannot communicate via Bluetooth, NFC, etc.

My library and this project (as I understand) currently don’t support Bluetooth communication between iOS and Android due to their OS restrictions.

azanli commented 6 years ago

@viri That's so cool. I really like what you've done here. I am hoping to be able to use this library in production very soon. I just noticed that this library is missing one of those license documents. Does the underlying library being a proprietary commercial product mean that there are restrictions that I should be aware of? Of course I am hoping to make a million bucks. XD

I have had a recent issue but I think I'll open up a different thread for that. Thank you for your commitment to solving this problem for us!!

EDIT: Nevermind the question, I found the answer in your license:

  (d) If You distribute or publish the Work or Derivative Works
      in one or more software application stores, including
      but not limited to Apple App Store and/or Google Play Store,
      You must include in its store application description
      on store's application page the following line (without quotes):
      "Mesh networking by http://underdark.io"