android - How to ask user to enable Bluetooth on NativeScript without use Native Code -
i need ask user enable bluetooth, not want use native methods of each platform, there standardized way in nativescript this?
which classes should used type of request code compatible both ios , android platforms, or whatever may come with?
i need code ios , android:
demoappmodel.prototype.doenablebluetooth = function () { bluetooth.enable().then(function(enabled) { if(!enabled) settimeout(function() { /* need code ios , android */ intent enablebtintent = new intent(bluetoothadapter.action_request_enable); startactivityforresult(enablebtintent, request_enable_bt); }, 500); }); };
you use nativescript-bluetooth plugin , use the method shown in demo app:
bluetooth.isbluetoothenabled().then(function(enabled) { // show alert dialog or nicer ui, if 'enabled' if false }); btw, on android can programmatically enable bluetooth on device (it ask user's consent) using this method of plugin:
bluetooth.enable().then(function(enabled) { /* .. */ });
Comments
Post a Comment