You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻找适配Sensoro 4AA信标的极简iOS/Android蓝牙触发通知APP

Hey there! Let’s walk through your request for a minimal app that detects Sensoro 4AA beacons and triggers custom alerts—prioritizing iOS, with Android as a backup.

Minimal App for Sensoro 4AA Beacon Detection & Custom Alerts

Option 1: iOS Shortcuts (No-Code, Built-In, Minimal)

Since you prefer iOS, this is the simplest solution without needing to build a custom app:

  • Open the Shortcuts app on your iPhone
  • Create a new personal automation:
    • Tap "Create Personal Automation" → Select "Beacon"
    • Tap "Add Beacon" to scan your Sensoro 4AA beacon (or manually enter its UUID, Major, and Minor values)
    • Under "Do", add your desired action:
      • For a custom text alert: Use the "Show Alert" action and input your message
      • To open a link: Use the "Open URL" action and paste your target link
  • Disable the "Ask Before Running" toggle so it triggers automatically when the beacon is detected
  • Ensure Bluetooth and Location Services are enabled (set Shortcuts to "Always" access in Settings → Privacy & Security → Location Services)

Option 2: Custom iOS App (Swift)

If you need more control over the UI or additional features, here’s a minimal implementation using CoreLocation:

Step 1: Configure Permissions

Add these entries to your Info.plist to request necessary access:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Need location access to detect beacons</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Need location access to detect beacons</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need Bluetooth access to detect beacons</string>

Step 2: Beacon Detection & Alert Logic

Create a manager class to handle beacon monitoring and alerts:

import CoreLocation
import UIKit

class BeaconManager: NSObject, CLLocationManagerDelegate {
    private let locationManager = CLLocationManager()
    
    // Configurable parameters (add a settings screen to edit these)
    var beaconUUID = UUID(uuidString: "YOUR_BEACON_UUID")!
    var beaconMajor = 123 // Replace with your beacon's major value
    var beaconMinor = 456 // Replace with your beacon's minor value
    var customAlertMessage = "Sensoro Beacon Detected!"
    var customLinkURL: URL? = URL(string: "https://your-custom-link.com")

    override init() {
        super.init()
        locationManager.delegate = self
        locationManager.requestAlwaysAuthorization()
        locationManager.startMonitoring(for: beaconRegion)
    }

    private var beaconRegion: CLBeaconRegion {
        CLBeaconRegion(
            uuid: beaconUUID,
            major: beaconMajor,
            minor: beaconMinor,
            identifier: "Sensoro4AA_Beacon"
        )
    }

    func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
        guard region is CLBeaconRegion, region.uuid == beaconUUID else { return }
        
        // Show custom alert on main thread
        DispatchQueue.main.async {
            let alert = UIAlertController(
                title: "Beacon Alert",
                message: self.customAlertMessage,
                preferredStyle: .alert
            )
            
            if let url = self.customLinkURL {
                alert.addAction(UIAlertAction(title: "Open Link", style: .default) { _ in
                    UIApplication.shared.open(url)
                })
            }
            
            alert.addAction(UIAlertAction(title: "OK", style: .cancel))
            UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true)
        }
    }
}
  • Add a settings screen with text fields to let users modify the configurable parameters at runtime.

Option 3: Custom Android App (Kotlin)

For Android, use the reliable Android Beacon Library to handle beacon detection:

Step 1: Add Dependencies

Add this to your module-level build.gradle:

dependencies {
    implementation 'org.altbeacon:android-beacon-library:2.21.4'
}

Step 2: Configure Permissions & Services

Update your AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application ...>
    <service android:name="org.altbeacon.beacon.service.BeaconService" android:enabled="true" android:exported="true"/>
    <service android:name=".BeaconMonitorService" android:foregroundServiceType="location"/>
</application>

Step 3: Beacon Monitoring Service

Create a foreground service to detect beacons and trigger notifications:

import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.IBinder
import androidx.core.app.NotificationCompat
import org.altbeacon.beacon.BeaconConsumer
import org.altbeacon.beacon.BeaconManager
import org.altbeacon.beacon.BeaconParser
import org.altbeacon.beacon.RangeNotifier
import org.altbeacon.beacon.Region

class BeaconMonitorService : android.app.Service(), BeaconConsumer {
    private lateinit var beaconManager: BeaconManager
    
    // Configurable parameters
    var beaconUUID = "YOUR_BEACON_UUID"
    var beaconMajor = 123
    var beaconMinor = 456
    var customAlertMessage = "Sensoro Beacon Detected!"
    var customLinkURL = "https://your-custom-link.com"

    override fun onCreate() {
        super.onCreate()
        beaconManager = BeaconManager.getInstanceForApplication(this)
        beaconManager.beaconParsers.add(BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"))
        beaconManager.bind(this)
    }

    override fun onBeaconServiceConnect() {
        val region = Region(
            "Sensoro4AA_Beacon",
            java.util.UUID.fromString(beaconUUID),
            beaconMajor.toLong(),
            beaconMinor.toLong()
        )
        
        beaconManager.addRangeNotifier { beacons, _ ->
            if (beacons.isNotEmpty()) {
                showAlertNotification()
            }
        }
        beaconManager.startRangingBeaconsInRegion(region)
        startForeground(1, createForegroundNotification())
    }

    private fun showAlertNotification() {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse(customLinkURL))
        val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)

        val notification = NotificationCompat.Builder(this, "BEACON_ALERT_CHANNEL")
            .setContentTitle("Beacon Alert")
            .setContentText(customAlertMessage)
            .setSmallIcon(R.drawable.ic_notification)
            .setContentIntent(pendingIntent)
            .setAutoCancel(true)
            .build()

        val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
        notificationManager.notify(2, notification)
    }

    private fun createForegroundNotification(): Notification {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val channel = NotificationChannel(
                "BEACON_FOREGROUND_CHANNEL",
                "Beacon Monitoring",
                NotificationManager.IMPORTANCE_LOW
            )
            getSystemService(NotificationManager::class.java).createNotificationChannel(channel)
        }
        return NotificationCompat.Builder(this, "BEACON_FOREGROUND_CHANNEL")
            .setContentTitle("Monitoring Beacons")
            .setContentText("Scanning for Sensoro 4AA beacon")
            .setSmallIcon(R.drawable.ic_notification)
            .build()
    }

    override fun onBind(intent: Intent?): IBinder? = null
    override fun onDestroy() {
        super.onDestroy()
        beaconManager.unbind(this)
    }
}
  • Add a settings activity to let users edit beacon parameters and custom alert content.

Key Notes

  • iOS requires "Always" location permission for background beacon detection.
  • Android 12+ needs explicit Bluetooth permissions in addition to location access.
  • Sensoro 4AA beacons use the iBeacon protocol, so the beacon layouts in the code above are compatible.

内容的提问来源于stack exchange,提问作者G. Weisz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:19:27