0

I have written a Solution that contains two Apps,
the first app acts like a remote control app and the second app display some stuff depending on the selection of the first app.

State Now:
Currently, both apps communicate over a Bluetooth connection using the MultipeerConnectivity.framework.

Problem:
I have always to pair both apps manually starting the apps.

Solution:
Starting both apps, they should detect each other and be paired automatically.

How could I solve my Problem, is there any alternative to the Bluetooth connection or can I set up the connection to have trusted devices or something like that?

kalpesh satasiya
  • 799
  • 8
  • 18
feldeOne
  • 417
  • 3
  • 18
  • 1
    You could use Core Bluetooth directly; have one app acts as a peripheral and the other as the central. – Paulw11 Jan 12 '18 at 09:35
  • @Paulw11 would this way solve the problem with manual pairing ? How would both apps establish the connection ? – feldeOne Jan 12 '18 at 09:45
  • 1
    Your central would scan for peripherals advertising your service. Your peripheral app would advertise that service. Your central app could automatically connect to any peripheral advertising that service or you could show the initial discovered peripheral to the user and once they have selected it, store the identifier in user defaults and automatically connect to that in future. – Paulw11 Jan 12 '18 at 09:47
  • Could you provide a simple sample code, maybe on github hosted sample or any tutorial ? Just to see how it works – feldeOne Jan 12 '18 at 09:51
  • https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/BestPracticesForInteractingWithARemotePeripheralDevice/BestPracticesForInteractingWithARemotePeripheralDevice.html thats exactly what I was looking for – feldeOne Jan 12 '18 at 10:12

1 Answers1

1

It's up to you as the developer how the pairing is implemented. You could even code a solution which requires no approval from the user; the app could pair automatically with any device looking for other peers (although this probably wouldn't be a good idea for a variety of reasons).

One possible solution for your problem:

The first time your devices pair, you generate a random UUID and save it on both devices for later use.

The next time your devices discover one another, they check to see if they have any matching UUIDs stored; if they do find a matching pair then you can let them connect automatically.

R.F. Nelson
  • 2,254
  • 2
  • 12
  • 24