24 lines
2.6 KiB
Markdown
24 lines
2.6 KiB
Markdown
# WRNexusInbox 0.1.0 preview
|
|
|
|
SwiftPM recipient client and SwiftUI `InboxView`, supporting iOS 15+ and macOS 12+. Distribution uses a versioned Git package; the release report records the published repository when available.
|
|
|
|
```swift
|
|
import WRNexusInbox
|
|
let inbox = try InboxClient(token: { try await yourBackend.fetchRecipientToken() })
|
|
InboxView(client: inbox) { message, action in
|
|
// Handle custom action.id. HTTPS links are handled by SwiftUI Link.
|
|
}
|
|
```
|
|
|
|
Your server issues a recipient token through the Notifications business API. Never embed a business API key. The token provider runs before each request/reconnect, allowing refresh. Configure a verified custom domain through `endpoint:`. API errors expose `InboxError.code`, `status` and `message`.
|
|
|
|
Async methods: `messages(limit:)`, `markRead(_:)`, `archive(_:)`, `preferences()`, `savePreferences(_:)`, `devices()`, `registerMobilePush(_:)`, `unregisterMobilePush(_:)`, `unregisterWebPush(_:)`, and `updates()`. Cancel the task consuming `updates()` on pause/disappear; the component manages its own subscription. Null quiet-hours/marketing-limit settings explicitly clear saved delivery rules. Omitted preference fields preserve existing settings. Writes are not retried.
|
|
|
|
Configure an active APNs or FCM connection in Notifications. The host requests `UNUserNotificationCenter` permission and registers with APNs or initializes Firebase. Convert the APNs `Data` device token to lowercase hexadecimal using `deviceToken.map { String(format: "%02x", $0) }.joined()`. Persist a random installation ID in the app's private storage and reuse it when the provider rotates the token. Pass `MobileRegistration(connectionId:installationId:name:token:marketingConsent:consentEvidence:)`; the platform defaults to `ios`. Retain the returned device ID per recipient. Marketing consent must reflect the recipient's real choice.
|
|
|
|
On logout, unregister the device ID for that recipient, remove their view, cancel subscription tasks and call `close()`. If unregister fails, have your backend deactivate the device. Create a new client for each new recipient. The host owns provider configuration, consent, permissions and account storage.
|
|
|
|
`swift test` verifies Foundation models, requests, errors, SSE parsing and logout behavior. Linux tests do not compile SwiftUI or prove iOS simulator/device behavior. Validate `InboxView` with an Apple SDK before a stable release; real APNs/FCM delivery remains a device acceptance check.
|
|
|
|
SwiftPM install: `.package(url: "https://git.workroot.in/Clintchiz/WRNexus-Mobile-SDKs.git", exact: "0.1.0")`. Flutter: Git dependency at the same URL, ref `0.1.0`, path `flutter`.
|