Hello All,
i have 4 proximity beacons and what I need to do s that when I enter the area of each one of them I need the code to transfer to another View controller to display some content. The problem is that when I put all the credentials( i made an app for each beacon in the Estimote cloud ) to get credentials of all the beacons I cannot detect them but when I put only one it works!
I need to put them all in the main page and the transfer to other pages from this page
can anyone help me with this, please ?
Thank you
import UIKit
import ARKit
import EstimoteProximitySDK
struct Content {
let title: String
let subtitle: String
}
@available(iOS 11.0, *)
class Question1ViewController: UIViewController, UICollectionViewDelegateFlowLayout {
//let userId = UserDefaults.standard.object(forKey: "userId") as? [String]
@IBOutlet weak var sceneView: ARSCNView!
var proximityObserver: ProximityObserver!
var flagCoconut = false
var flagMint = false
var flagIce = false
var nearbyContent = [Content]()
override func viewDidLoad() { DispatchQueue.main.async {
super.viewDidLoad()
///////////////////// Coconut /////////////////////
let Coconut = CloudCredentials(appID: "jawab-test-2m5", appToken: "6ff2355c245c7d7953c64eb5c2a912ba")
self.proximityObserver = ProximityObserver(credentials: Coconut, onError: { error in
print("ProximityObserver error: \(error)")
})
let zone = ProximityZone(tag: "jawab-test-2m5", range: ProximityRange.near)
zone.onEnter = { contexts in
print("Enter")
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let QuestionViewController = storyBoard.instantiateViewController(withIdentifier: "Questionscene") as! QuestionViewController
self.present(QuestionViewController, animated: true, completion: nil)
zone.onExit = { contexts in
print("Exit")
// self.flagCoconut = false
}
}
self.proximityObserver.startObserving([zone])
///////////////////// Mint /////////////////////
let mint = CloudCredentials(appID: "reem-badr-s-proximity-for--6o4", appToken: "8be2dff5dc16b9747b7fafe97ff53708")
self.proximityObserver = ProximityObserver(credentials: mint, onError: { error in
print("ProximityObserver error: \(error)")
})
let zoneMint = ProximityZone(tag: "reem-badr-s-proximity-for--6o4", range: ProximityRange.near)
if !self.flagCoconut {
zoneMint.onEnter = { contexts in
print("enter")
self.flagMint = true
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let QuestViewController = storyBoard.instantiateViewController(withIdentifier: "questScene") as! QuestViewController
self.present(QuestViewController, animated: true, completion: nil)
}
zoneMint.onExit = { contexts in
print("Exit")
self.flagMint = false
}
}
self.proximityObserver.startObserving([zoneMint])
////////////////////ice //////////////////////
let ice = CloudCredentials(appID: "ice---jawwab-for-a-single--24i", appToken: "4cc922d2dc4834858e08255a67e65785")
self.proximityObserver = ProximityObserver(credentials: ice, onError: { error in
print("ProximityObserver error: \(error)")
})
let zoneIce = ProximityZone(tag: "ice---jawwab-for-a-single--24i", range: ProximityRange.near)
// if !self.flagCoconut {
zoneIce.onEnter = { contexts in
print("enter ice ")
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let QuestionViewController = storyBoard.instantiateViewController(withIdentifier: "Questionscene") as! QuestionViewController
self.present(QuestionViewController, animated: true, completion: nil)
}
zoneIce.onExit = { contexts in
print("Exit")
}
self.proximityObserver.startObserving([zoneIce])
//////////////
}
///////////////ice////////////////////////
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneView.session.pause()
}
}