Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying SDK in swift #2

Open
vegetablesalad opened this issue Nov 6, 2019 · 2 comments
Open

Trying SDK in swift #2

vegetablesalad opened this issue Nov 6, 2019 · 2 comments

Comments

@vegetablesalad
Copy link

I'm having some issues in replicating code in swift:
Am I missing something ?

import mokoBeaconSDK


@objc(BeaconScanner) class BeaconScanner : HCKBeaconCentralManager,HCKCentralScanDelegate {
    
    
    
    func centralManagerScanNewDeviceModel(_ beaconModel: HCKBeaconBaseModel!, manager: HCKBeaconCentralManager!) {
        print("centralManagerScanNewDeviceModel")
    }
    
    func centralManagerStartScan(_ manager: HCKBeaconCentralManager!){
        print("centralManagerStartScan")
    }
    
    func centralManagerStopScan(_ manager: HCKBeaconCentralManager!){
        print("centralManagerStopScan")
    }
    

    

    public func initialize() {
        print("initialize moko scan")
        let manager = HCKBeaconCentralManager()
        manager.scanDelegate=self
        manager.startScaniBeacons()
        
    }


   
}
@vegetablesalad
Copy link
Author

Seems that this should be the correct way to go:
But it still doesn't return any results

    public func initialize() {
        HCKBeaconCentralManager.sharedInstance().scanDelegate=self
        HCKBeaconCentralManager.sharedInstance().stateDelegate=self
        HCKBeaconCentralManager.sharedInstance().startScaniBeacons()
    }

@vegetablesalad
Copy link
Author

As per suggestion I added a delay before scanning. It doesn't resolve the issue:

import mokoBeaconSDK



@objc(BeaconScanner) class BeaconScanner : HCKBeaconCentralManager,HCKCentralStatesChangedDelegate,HCKCentralScanDelegate {
    
    public func centralManagerStateChanged(_ managerState: HCKBeaconCentralManagerState, manager: HCKBeaconCentralManager!) {
        print(" centralManagerStateChanged")
    }
    
    public func peripheralConnectStateChanged(_ connectState: HCKBeaconConnectStatus, manager: HCKBeaconCentralManager!) {
        print(" peripheralConnectStateChanged")
    }
    
    public func centralManagerScanNewDeviceModel(_ beaconModel: HCKBeaconBaseModel!, manager: HCKBeaconCentralManager!) {
        print(" centralManagerScanNewDeviceModel")
    }
    
    public func centralManagerStartScan(_ manager: HCKBeaconCentralManager!){
        print(" centralManagerStartScan")
    }
    
    public func centralManagerStopScan(_ manager: HCKBeaconCentralManager!){
        print(" centralManagerStopScan")
    }
        

    public func initialize() {

        let instance = HCKBeaconCentralManager.sharedInstance()
        instance?.scanDelegate=self
        instance?.stateDelegate=self
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
            print(" start scan")
            instance?.startScaniBeacons()
        }
        
    }


   
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant