Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve 'init(proximityUUID:identifier:)' was deprecated in iOS 13.0 for iBeacon

Tags:

ios

swift

ios13

I want to receive RSSI of iBeacon on my iOS application this code can run on iOS12. Now I have updated to iOS 13 this code can't run.

and alert

'init(proximityUUID:identifier:)' was deprecated in iOS 13.0 'startRangingBeacons(in:)' was deprecated in iOS 13.0 'stopRangingBeacons(in:)' was deprecated in iOS 13.0

How to fix this problem?

like image 931
Kittisak Sridet Avatar asked Dec 08 '25 08:12

Kittisak Sridet


2 Answers

If you look at the documentation for the method your are using it tells you that it was deprecated in iOS 13 and also tells you what to use instead.

In case the link breaks, this is the alternative option:

init(uuid:major:minor:identifier:)

Check the documentation for the other methods and it will tell you which alternatives to use.

Now.. to configure your app to switch between methods based on the iOS version you can use an @available check..

if #available(iOS 13, *) {
    // use the shiny new one
} else {
    // use the old one
} 
like image 150
Scriptable Avatar answered Dec 10 '25 02:12

Scriptable


After reading the docs I changed my code from:

let beaconRegion = CLBeaconRegion(proximityUUID: uuid, major: 123, minor: 456, identifier: "MyBeacon")

To:

let beaconRegion = CLBeaconRegion(uuid: uuid, major: 123, minor: 456, identifier: "MyBeacon")

and resolved the first issue.

like image 24
Yakimasy Avatar answered Dec 10 '25 01:12

Yakimasy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!