iOS Question Configurate UUID of an IBeacon for IOS

Humberto

Active Member
Licensed User
I found in apple documentation how to configurate a UUID, major and minor for Iphone transmit as Ibeacon ( peripheral )

I don´t know how to write in B4I

https://developer.apple.com/documentation/corelocation/turning_an_ios_device_into_an_ibeacon?language=objc

This code not generate an IBeacon just a regular bluetooth port

B4X:
peripheral.Initialize("Peripheral")
 peripheral.Start("B4iPeripheral")

I found a app that do it already

https://itunes.apple.com/us/app/ble-scanner-4-0/id1221763603?mt=8

Thanks

Humberto
 
Last edited:

Humberto

Active Member
Licensed User
This error occurs

Application_Start
Error occurred on line: 55 (Main)
Object was not initialized (NSObject)
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
BLE IBeacon -[B4IObjectWrapper object] + 200
BLE IBeacon -[B4INativeObject RunMethod::] + 84
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
BLE IBeacon +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
BLE IBeacon -[B4IShell runMethod:] + 588
BLE IBeacon -[B4IShell raiseEventImpl:method:args::] + 1908
BLE IBeacon -[B4IShellBI raiseEvent:event:params:] + 1328
BLE IBeacon +[B4IDebug delegate:::] + 52
BLE IBeacon -[b4i_main _createbeaconregion::::] + 670
BLE IBeacon -[b4i_main _application_start:] + 1432
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
BLE IBeacon +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
BLE IBeacon -[B4IShell runMethod:] + 588
BLE IBeacon -[B4IShell raiseEventImpl:method:args::] + 2192
BLE IBeacon -[B4IShellBI raiseEvent:event:params:] + 1328
BLE IBeacon __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 1524
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1574
CoreFoundation CFRunLoopRunSpecific + 520
CoreFoundation CFRunLoopRunInMode + 108
GraphicsServices GSEventRunModal + 160
UIKit UIApplicationMain + 144
BLE IBeacon main + 106
libdyld.dylib <redacted> + 2
)
Application_Active

The line is
B4X:
    Return cl.Initialize("CLBeaconRegion").RunMethod("alloc", Null) _
    .RunMethod("initWithProximityUUID:major:minor:identifier:", _
    Array(u, Major, Minor, Identifier))
 

Attachments

Last edited:

Erel

Administrator
Staff member
Licensed User
Put a breakpoint in line 50 and check the value of 'u'. Is it initialized?

Are you testing it on a real device? Which version of iOS?
 

Humberto

Active Member
Licensed User
I tested with Iphone 4s IOS 9.3.5 and IPad IOS 10.3.3.3

The error in IPad

Application_Start
Error occurred on line: 55 (Main)
Object was not initialized (NSObject)
Stack Trace: (
CoreFoundation <redacted> + 152
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
BLE IBeacon -[B4IObjectWrapper object] + 200
BLE IBeacon -[B4INativeObject RunMethod::] + 84
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
BLE IBeacon +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
BLE IBeacon -[B4IShell runMethod:] + 588
BLE IBeacon -[B4IShell raiseEventImpl:method:args::] + 1908
BLE IBeacon -[B4IShellBI raiseEvent:event:params:] + 1328
BLE IBeacon +[B4IDebug delegate:::] + 52
BLE IBeacon -[b4i_main _createbeaconregion::::] + 670
BLE IBeacon -[b4i_main _application_start:] + 1432
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
BLE IBeacon +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
BLE IBeacon -[B4IShell runMethod:] + 588
BLE IBeacon -[B4IShell raiseEventImpl:method:args::] + 2192
BLE IBeacon -[B4IShellBI raiseEvent:event:params:] + 1328
BLE IBeacon __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib _dispatch_main_queue_callback_4CF + 902
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 848
CoreFoundation CFRunLoopRunSpecific + 470
CoreFoundation CFRunLoopRunInMode + 104
GraphicsServices GSEventRunModal + 80
UIKit UIApplicationMain + 150
BLE IBeacon main + 106
libdyld.dylib <redacted> + 2
)
Application_Active
 

Attachments

Erel

Administrator
Staff member
Licensed User
What is the output of this code:
B4X:
Sub CreateBeaconRegion (UUID As String, Major As Int, Minor As Int, Identifier As String) As NativeObject
   Dim cl As NativeObject
   Dim u As NativeObject
   u = u.Initialize("NSUUID").RunMethod("alloc", Null).RunMethod("initWithUUIDString:", Array(UUID))
   Log(u.IsInitialized)
   Log(u)
   cl = cl.Initialize("CLBeaconRegion").RunMethod("alloc", Null)
   Log("test")
   cl = cl.RunMethod("initWithProximityUUID:major:minor:identifier:", _
       Array(u, Major, Minor, Identifier))
   Log(cl)   
   Return cl
End Sub
?
 

Humberto

Active Member
Licensed User
Application_Start
true
<B4INativeObject: <__NSConcreteUUID 0x175d3ee0> 68753A44-4D6F-1226-9C60-0050E4C00067>
Error occurred on line: 77 (Main)
Object was not initialized (NSObject)
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
BLE IBeacon -[B4IObjectWrapper object] + 200
BLE IBeacon -[B4INativeObject RunMethod::] + 84
BLE IBeacon -[b4i_main _createbeaconregion::::] + 2198
BLE IBeacon -[b4i_main _application_start:] + 1432
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
BLE IBeacon +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
BLE IBeacon -[B4IShell runMethod:] + 588
BLE IBeacon -[B4IShell raiseEventImpl:method:args::] + 1908
BLE IBeacon -[B4IShellBI raiseEvent:event:params:] + 1328
BLE IBeacon __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 1524
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1574
CoreFoundation CFRunLoopRunSpecific + 520
CoreFoundation CFRunLoopRunInMode + 108
GraphicsServices GSEventRunModal + 160
UIKit UIApplicationMain + 144
BLE IBeacon main + 106
libdyld.dylib <redacted> + 2
)
Application_Active

Line 77 cl = cl.Initialize("CLBeaconRegion").RunMethod("alloc", Null)
 
Last edited:

Erel

Administrator
Staff member
Licensed User
Are you sure that your devices support BLE?

Can you test it with an iOS 11+ device?
 

Humberto

Active Member
Licensed User
Hi Erel

I don´t have at this moment, an Iphone witj IOS 11

This software I installed in my device and works as an Ibeacon

Ibeacon is from IOS 7.

Follow the image of my Iphone 4S configurated as Ibeacon and a Moto X reading it

I installed the software that read IBeacon and aldo works ( your example ).

Could you run this code ?
 

Attachments

Erel

Administrator
Staff member
Licensed User
These are the same API that is called by the code I posted.
 

Humberto

Active Member
Licensed User
This is not working in IOS 9 and IOS 10, but there are some apk that Works with this versions.

What to do?

I'll try to find an IOS 11 or 12 to test, but still. Will remain this isues
 

Erel

Administrator
Staff member
Licensed User
It does look that your devices do not support this feature. It is worth testing it with a newer device.
 
Top