nativescript-community / nativescript-community/ble

(iOS) startScanning() not working

Open
#267 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
202
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm facing an issue that I can't explain when trying to get info on a BLE device. StartScanning() seems to not doing anything only on iOS. On Android, everything works as expected.

Here's my method and on iOS, nothing comes from onDiscovered :

bleRoutine(){
        try{
            let self = this;
            this.bluetooth.startScanning({
                //filters: [{serviceUUID:'00001000-0000-1000-8000-00805f9b34fb'}],
                seconds: 3,
                avoidDuplicates: true,
                onDiscovered: function (peripheral) {
                    if(peripheral.name == "T201"){
                        let dataView = new DataView(peripheral.advertismentData.manufacturerData);
                    }
                }
            }).then(function() {
                //console.log("scanning complete");
                //if(!self.bleStop) self.bleRoutine();
                // self.connectToDevice();
                //self.bleConnections();
            }, function (err) {
                //console.log("error while scanning: " + err);
            });
        }catch(e){
            console.log("ble catch");
            console.log(e);
        }
    }

Here's what I added in my Info.plist :

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Our app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>  
<string> Our app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSLocationWhenInUseUsageDescription</key>  
<string> Our app uses location</string>

I also checked Uses Bluetooth LE accessory in Background Modes in Xcode.

I also have a bluetooth message when I start the app as expected. I am in native script version 8.1.4 and "@nativescript-community/ble": "^3.1.15"

Am I missing something ? (maybe something obvious that doesn't ring a bell in my head)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the startScanning() call and the iOS permission entries shown in Info.plist, then trace the iOS BLE scanning entry point used by @nativescript-community/ble. Reproduce the scan on iOS and verify whether onDiscovered receives a peripheral; completion means scanning discovers the same BLE device that Android finds.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, typescript
Domain
mobile, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.