mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
- Hub: add a background APNs transport and a throttled widget-state notifier; fan out silent content-available wakes to registered iOS devices on widget-visible session changes. - iOS: handle silent pushes and BGAppRefreshTask by refreshing the active hub list and waiting for the App Group snapshot write; enable background modes; register APNs tokens even when alert permission is denied. - Store: repair a drifted fcm_devices schema missing push_key so /api/devices/register no longer 500s (this also restores alert push registration on the affected database). - Document the silent-refresh fallback and its best-effort limits. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
34 lines
961 B
Swift
34 lines
961 B
Swift
import XCTest
|
|
@testable import Hapi
|
|
|
|
@MainActor
|
|
final class WidgetRefreshTests: XCTestCase {
|
|
func testSilentPushDetection() {
|
|
XCTAssertTrue(WidgetRefreshScheduler.isSilentPush([
|
|
"aps": ["content-available": 1]
|
|
]))
|
|
XCTAssertTrue(WidgetRefreshScheduler.isSilentPush([
|
|
"aps": ["content-available": true]
|
|
]))
|
|
XCTAssertFalse(WidgetRefreshScheduler.isSilentPush([
|
|
"aps": ["alert": ["title": "HAPI"]]
|
|
]))
|
|
XCTAssertFalse(WidgetRefreshScheduler.isSilentPush([:]))
|
|
}
|
|
|
|
func testBridgeForwardsTheInstalledRefresh() async {
|
|
let bridge = WidgetRefreshBridge()
|
|
let missing = await bridge.refresh()
|
|
XCTAssertFalse(missing)
|
|
|
|
var calls = 0
|
|
bridge.install {
|
|
calls += 1
|
|
return true
|
|
}
|
|
let refreshed = await bridge.refresh()
|
|
XCTAssertTrue(refreshed)
|
|
XCTAssertEqual(calls, 1)
|
|
}
|
|
}
|