Day 7: Stay in the Loop with Canny.io! ๐
In the seventh post of #30DaysOfSwift series, I am sharing about Canny.ioโa great tool for collecting user feedback and tracking feature requests.
Hereโs how you can easily add Canny.io to your app:
Steps to Integrate Canny.io:
1. Set Up Your Canny.io Account:
- If you havenโt already, sign up at Canny.io and create a new board for your app to track feedback.
- Go to
Settings > Installation
and copy the Board ID youโll need to integrate Canny. - Open Canny in a WebView: Since Canny operates as a web-based service, weโll add a simple WebView to your SwiftUI app to open the feedback form.
import SwiftUI
import WebKit
struct CannyView: UIViewRepresentable {
let urlString: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
if let url = URL(string: urlString) {
let request = URLRequest(url: url)
uiView.load(request)
}
}
}
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
Text("Got feedback? Weโd love to hear it!")
.padding()
Button("Submit Feedback") {
// Open the Canny feedback form
openCannyForm()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
}
}
func openCannyForm() {
if let window = UIApplication.shared.windows.first {
let rootView = CannyView(urlString: "https://yourapp.canny.io/feedback") // Replace with your Canny feedback URL
window.rootViewController = UIHostingController(rootView: rootView)
window.makeKeyAndVisible()
}
}
}
3. Customize Your Feedback Form:
- Replace
"https://yourapp.canny.io/feedback"
with the actual URL of your Canny feedback board. - You can also add parameters like userID and email to pre-fill information for users who are logged in.
Happy Coding!
Top comments (0)