https://github.com/queeniecplusplus/ios_back_3
to do a iBeacon Sensor feature with sys notification when app is running in background
https://github.com/queeniecplusplus/ios_back_3
ble cllocationmanager ibeacon ios11 swift4 swift5 xcode10 xcode12
Last synced: 6 days ago
JSON representation
to do a iBeacon Sensor feature with sys notification when app is running in background
- Host: GitHub
- URL: https://github.com/queeniecplusplus/ios_back_3
- Owner: QueenieCplusplus
- Created: 2021-01-27T06:46:34.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-29T12:28:51.000Z (about 5 years ago)
- Last Synced: 2025-03-13T13:13:46.702Z (11 months ago)
- Topics: ble, cllocationmanager, ibeacon, ios11, swift4, swift5, xcode10, xcode12
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru#apple-ios-swift-溫故愛鳳---計畫復甦
- Size: 1.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# iOS_Back_3
to do a iBeacon Sensor feature with sys notification when app is running in background

1. define K/V in info propert list.

2. code in ViewController.
//
// ViewController.swift
// KatesIBeaconBLEapp
//
// Created by KatesAndroid on 2021/1/27 PM2 :20 ~
//
import UIKit
import CoreBluetooth
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
let cllm = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// after nib.
cllm.requestAlwaysAuthorization()
cllm.delegate = self
// search for Beacon's UUID, which is 20 bytes.
let uuid = UUID(uuidString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D")
let region = CLBeaconRegion(uuid: uuid!, identifier: "Kates Region")
// this app helps to detect info of nearby beacon device.
// cllm.startRangingBeacons is deprecated.
cllm.startMonitoring(for: region)
// to know how many and what are they
// matters with major, minor, accury
//cllm.startRangingBeacons(satisfying: <#T##CLBeaconIdentityConstraint#>)
}
// when app running at background.
// method below can be called.
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
print("Enter\(region.identifier)")
}
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
print("Exit\(region.identifier)")
}
}
ref: https://medium.com/彼得潘的-swift-ios-app-開發問題解答集/swift-ibeacon-app-程式設計-cd89f59f735b
* setup for allowing BLE app running in Background.
https://github.com/QueenieCplusplus/iOS_Back_16/blob/main/README.md
