How to turn on Bluetooth from inside Unity?

Hi,

I am looking for a way to turn on Bluetooth on Android and iOS devices from inside my unity application or to trigger a prompt to ask the user for this (like in the example img).

Does anyone know of an asset, that can help me with this or if Unity has this feature already?

Help will be greatly appreciated!

Kind regards,
Rasmus Lindholm

public void setBluetoothEnabled()
{
using (AndroidJavaObject activity = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”).GetStatic(“currentActivity”))
{
try
{
using (var BluetoothManager = activity.Call(“getSystemService”, “bluetooth”))
{
using (var BluetoothAdapter = BluetoothManager.Call(“getAdapter”))
{
BluetoothAdapter.Call(“enable”);
}

                }
            }
            catch (Exception e)
            {
            }
        }
    }

@KuboRobot This will silently turn on bluetooth, without pop-ups because you grant permissions while installing an app, also, you have to add this to your AndroidManifest.xml:

uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
uses-permission android:name="android.permission.BLUETOOTH" (probably not needed)

@adammak23
Worked for us in Unity 2017.3.0f3 after this small change, thanks: BluetoothAdapter.Call<b><bool></b>("enable");

This is the fastest way to turn ON/OFF bluetooth in android. How to Turn ON/OFF Bluetooth, Fix Bluetooth missing Windows you can follow it if you want to know how to turn ON bluetooth on windows 10.