-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: [vision-os-sample-app][7/n] SDK Initialization view
This is a PR in a series of PRs to build sample app that runs Identify and Track in VisionPro For more context: - See the project [one pager](https://www.notion.so/custio/Spacial-Identify-and-Tracking-6587d848bbde494095c0585237326ed3?pvs=4) - See [Linear Issue](https://linear.app/customerio/issue/MBL-115/sample-app-for-visionpro) This PR introduces a the Initialization view where that demonstrates the usage of the `initialize` API
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Apps/VisionOS/VisionOS/APIViews/SDKInitializationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import MarkdownUI | ||
import SwiftUI | ||
|
||
struct SDKInitializationView: View { | ||
@EnvironmentObject var viewModel: ViewModel | ||
@State var workspaceSettings = AppState.shared.workspaceSettings | ||
|
||
let onSuccess: (_ workspaceSettings: WorkspaceSettings) -> Void | ||
|
||
var body: some View { | ||
ScrollView(.vertical) { | ||
VStack(alignment: .leading) { | ||
Markdown { | ||
""" | ||
You must have a cdp api key in order to initialize and use the SDK. | ||
Click [here](https://customer.io/docs/sdk/ios/quick-start-guide/#prerequisites) to learn more | ||
about the prerequisites. | ||
```swift | ||
CustomerIO.initialize(withConfig: | ||
SDKConfigBuilder(cdpApiKey: "\(workspaceSettings.cdpApiKy)") | ||
.build()) | ||
``` | ||
""" | ||
} | ||
FloatingTitleTextField(title: "CDP API KEY", text: $workspaceSettings.cdpApiKy) | ||
.textInputAutocapitalization(.never) | ||
.autocorrectionDisabled() | ||
|
||
Button("Initialize") { | ||
if !workspaceSettings.isSet() { | ||
viewModel.errorMessage = "Please make sure to enter the CDP API Key" | ||
return | ||
} | ||
AppState.shared.workspaceSettings = workspaceSettings | ||
onSuccess(AppState.shared.workspaceSettings) | ||
} | ||
|
||
Spacer() | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
MainLayoutView(selectedExample: .constant(.initialize)) { | ||
SDKInitializationView { _ in } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters