https://github.com/yapstudios/metabind-sample-retail-apple
https://github.com/yapstudios/metabind-sample-retail-apple
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yapstudios/metabind-sample-retail-apple
- Owner: yapstudios
- Created: 2025-12-18T17:08:42.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-30T17:16:48.000Z (5 months ago)
- Last Synced: 2026-01-31T10:19:42.152Z (5 months ago)
- Language: Swift
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Metabind Sample Retail
A minimal SwiftUI sample app demonstrating how to integrate the Metabind SDK into an iOS application.
## Overview
This project provides a starting point for building iOS apps with server-driven UI powered by Metabind. It shows the essential steps for initializing the Metabind client, displaying content, and handling navigation between pages.
## Requirements
- Xcode 15.0 or later
- iOS 17.0 or later
- A Metabind account with valid API credentials
## Getting Started
1. Clone or download this repository.
2. Open `MetabindSampleRetail.xcodeproj` in Xcode.
3. In `MetabindSampleRetailApp.swift`, replace the placeholder values with your credentials from the [Metabind dashboard](https://metabind.ai):
- `apiKey`
- `organizationId`
- `projectId`
- `contentId` (for your root content page)
4. Build and run the app on a simulator or device.
## Project Structure
```
MetabindSampleRetail/
├── MetabindSampleRetailApp.swift # App entry point and main content view
└── Assets.xcassets/ # App icons and colors
```
## Key Concepts
### Client Initialization
The `MetabindClient` is initialized with your API credentials and injected into the SwiftUI environment:
```swift
@State var client = MetabindClient(
url: URL(string: "https://api.metabind.ai/graphql")!,
ws: URL(string: "wss://ws-api.metabind.ai")!,
apiKey: "your-api-key",
organizationId: "your-org-id",
projectId: "your-project-id"
)
```
### Displaying Content
Use `MetabindView` to render content by its ID:
```swift
MetabindView(contentId: "your-content-id")
```
### Handling Navigation
Listen for `metabind.content` actions to navigate between content pages:
```swift
.onMetabindAction { action in
if action.name == "metabind.content",
let contentId = action.props["contentId"] as? String {
path.append(Destination.content(id: contentId))
}
}
```
## Resources
- [Metabind Documentation](https://docs.metabind.ai)
- [Metabind Dashboard](https://metabind.ai)
## License
This sample code is provided for demonstration purposes.