VNAPNIC / flutter_nearby_connections

Flutter plugin support peer-to-peer connectivity and the discovery of nearby devices for Android vs IOS
https://pub.dev/packages/flutter_nearby_connections
BSD 2-Clause "Simplified" License
106 stars 68 forks source link

Issues with Flutter (Android) -> Native Android (Kotlin/Java) nearby connection. #32

Open reducedcarpet opened 2 years ago

reducedcarpet commented 2 years ago

Hey, I was trying to get a new flutter app to connect to an old / already made Android Native app written in Kotlin/Java, with the Kotlin side as the advertiser. But I couldn't get them to connect until I examined the code.

Setting the Service Name on the Kotlin side to "flutter_nearby_connections" made it connect, probably due to that name being hard wired into the Android plugin in Flutter Nearby Connections. ( const val SERVICE_ID = "flutter_nearby_connections" )

So the Native code became:

Nearby.getConnectionsClient(this).startAdvertising(
                    deviceShortInfoString,
                    "flutter_nearby_connections",
                    connectionLifecycleCallback,
                    advertisingOptions)

For a good while I tried to change the serviceType on the flutter side to be exactly the same as the advertiser service name but obviously that didn't work. Is that only for iOS?

So my question is: Would it be possible to pass in a custom string into the flutter code to set the service name to something other than flutter_nearby_connections? That would make it a lot easier to work with legacy code from android native, especially if you don't want cross-talk between two different nearby sessions. Which is something we have wanted in the past.