permissions-registration

作成者: facebook

Meta AIへのアプリ登録、カメラ権限のフロー

npx skills add https://github.com/facebook/meta-wearables-dat-ios --skill permissions-registration

Permissions & Registration (iOS)

Register your app with Meta AI, then request the device permissions it needs.

The DAT SDK separates two concepts:

  1. Registration — Your app registers with Meta AI to become a permitted integration
  2. Device permissions — After registration, request specific device permissions (e.g., camera)

All permission grants occur through the Meta AI companion app.

Registration flow

Start registration

func startRegistration() async throws {
    try await Wearables.shared.startRegistration()
}

This opens the Meta AI app where the user approves your app. Meta AI then calls back via your URL scheme.

Handle the callback

Filter on the metaWearablesAction query item so unrelated deep links are not forwarded to the SDK:

.onOpenURL { url in
    guard
        let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
        components.queryItems?.contains(where: { $0.name == "metaWearablesAction" }) == true
    else {
        return
    }
    Task {
        do {
            _ = try await Wearables.shared.handleUrl(url)
        } catch let error as RegistrationError {
            showError(error.description)
        } catch {
            showError(error.localizedDescription)
        }
    }
}

Observe registration state

Task {
    for await state in Wearables.shared.registrationStateStream() {
        switch state {
        case .registered:
            // App is registered, can request permissions
        case .unavailable:
            // Registration is unavailable
        case .available:
            // Ready to register
        case .registering:
            // Registration in progress
        }
    }
}

Unregister

func startUnregistration() async throws {
    try await Wearables.shared.startUnregistration()
}

Camera permissions

Check permission status

let status = try await Wearables.shared.checkPermissionStatus(.camera)

Request permission

let status = try await Wearables.shared.requestPermission(.camera)

The SDK opens Meta AI for the user to grant access. Users can choose:

  • Allow once — temporary, single-session grant
  • Allow always — persistent grant

Multi-device behavior

Users can link multiple glasses to Meta AI. The SDK handles this transparently:

  • Permission granted on any linked device means your app has access
  • You don't need to track which device has permissions
  • If all devices disconnect, permissions become unavailable

Typed errors

Registration and permission APIs use typed throws. Prefer error.description or error.localizedDescription over your own error strings:

  • startRegistration() throws RegistrationError: .alreadyRegistered, .configurationInvalid, .metaAINotInstalled, .networkUnavailable, .unknown
  • startUnregistration() throws UnregistrationError: .alreadyUnregistered, .configurationInvalid, .metaAINotInstalled, .unknown
  • handleUrl(_:) throws WearablesHandleURLError: .registrationError, .unregistrationError
  • checkPermissionStatus(_:) and requestPermission(_:) throw PermissionError: .noDevice, .noDeviceWithConnection, .connectionError, .metaAINotInstalled, .requestInProgress, .requestTimeout, .internalError
  • openFirmwareUpdate() and openDATGlassesAppUpdate() throw NavigationError: .metaAINotInstalled, .notRegistered

Update flows

When a device reports compatibility() == .deviceUpdateRequired, offer a firmware update. When session start reports DeviceSessionError.datAppOnTheGlassesUpdateRequired, offer the glasses app update. Both open Meta AI:

try await Wearables.shared.openFirmwareUpdate()
try await Wearables.shared.openDATGlassesAppUpdate()

Developer Mode vs Production

ModeRegistration behavior
Developer ModeRegistration always allowed. MetaAppID is empty, 0, or an unexpanded $(META_APP_ID) placeholder, so the SDK skips attestation
ProductionMetaAppID, ClientToken, and TeamID must all be set, and users must be in the proper release channel

For production, get your app ID and client token from the Wearables Developer Center, and use your Apple Developer Team ID for TeamID.

Prerequisites

  • Registration requires an internet connection
  • Meta AI companion app must be installed
  • For Developer Mode: enable in Meta AI > Settings > Your glasses > Developer Mode

Links

facebookのその他のスキル

gc-safe-coding
facebook
完全な説明と根拠については、doc/GCSafeCoding.md を参照してください。
app-review-prep
facebook
MetaアプリをApp Reviewに備えて準備します — 現在のステータス、未対応の要件、付与済みの権限、提出履歴を確認します。アプリを提出する前に使用してください…
api-health
facebook
MetaアプリのAPIヘルスを監視 — レート制限、コールボリューム、APIの非推奨化をチェック。スロットリングの診断、キャパシティ計画、APIバージョンへの準備に使用…
debug-webhooks
facebook
Metaアプリのウェブフック問題をトラブルシューティング — アクティブなサブスクリプションを検査し、設定ミスを特定し、テストペイロードを送信して配信を確認します。次の場合に使用…
api-integration
facebook
開発者をMeta APIインテグレーションのゼロからのセットアップに導く — 適切なAPIを発見し、セットアップガイド、認証要件を取得し、…
webhook-setup
facebook
Metaアプリ用のwebhookをエンドツーエンドで設定 — 利用可能なトピックを発見し、フィールドに購読し、テストペイロードで検証します。webhookの設定時に使用します…
test-ui
facebook
iwsdk CLIを使用して、ポークの例に対してテストUIシステム(PanelUI、ScreenSpace)をテストします。
flags
facebook
Reactのリリースチャンネル間でフィーチャーフラグの状態を検査・比較します。全チャンネル(www、www-modern、canary、next、experimental、rnバリアント)のフラグを表示するか、--diffで特定のチャンネルを比較します。出力形式はデフォルトのテーブル表示、CSVエクスポート、クリーンアップステータスグループ化から選択可能。フラグの状態は記号で示されます:有効(✅)、無効(❌)、バリアントテスト中(🧪)、プロファイリングのみ(📊)。よくある落とし穴:__VARIANT__フラグはwww上で両方の状態でテストされます。--diffを使用して意味のある差異を特定してください...