Challenge View
Exciting Challenges: Drive Engagement and Motivation.
- Fun and Competitive: Quick challenges with leaderboards for friendly competition
- Boost Activity: Keep fitness exciting and rewarding for users
- Easy Integration: Add dynamic challenges effortlessly to your app
You can find exercises in our exercise library, or create your own exercises in our admin portal.
Challenge Integration
Display a challenge by exercise name or ID:
1kinestex.createChallengeView(
2 exercise: challengeExercise, // exercise name or ID
3 duration: 100, // duration of challenge in seconds
4 user: nil, // Optionally pass user details
5 showLeaderboard: true, // showLeaderboard prompts a user to enter a challenge at the end (true by default)
6 isLoading: $isLoading,
7 customParams: ["style": "dark"], // dark or light theme
8 onMessageReceived: { message in
9 switch message {
10 case .exit_kinestex(let data):
11 showKinesteX = false // dismiss the view
12 default:
13 print("Received \(message)")
14 break
15 }
16 }
17)Complete Example
Full implementation example with challenge setup:
1import SwiftUI
2import KinesteXAIKit
3
4struct ChallengeIntegrationView: View {
5 @State private var showKinesteX = false
6 @State private var isLoading = false
7
8 // Initialize KinesteXAIKit
9 // Replace with your KinesteX credentials
10 let kinesteXKit = KinesteXAIKit(
11 apiKey: "YOUR API KEY",
12 companyName: "YOUR COMPANY NAME",
13 userId: "YOUR USER ID"
14 )
15
16 // Challenge parameters
17 let challengeExercise = "Squats"
18 let challengeDuration = 100 // Duration in seconds
19 let showLeaderboardAfterChallenge = true
20
21 var body: some View {
22 VStack {
23 Text("KinesteX Challenge Integration")
24 .font(.title)
25 .padding()
26
27 Spacer()
28
29 Button(action: {
30 showKinesteX.toggle()
31 }) {
32 Text("Start \(challengeExercise) Challenge (\(challengeDuration)s)")
33 .font(.title3)
34 .foregroundColor(.white)
35 .bold()
36 .padding()
37 .frame(maxWidth: .infinity)
38 .background(Color.red.cornerRadius(10))
39 .padding(.horizontal)
40 }
41 .padding()
42
43 Spacer()
44 }
45 .fullScreenCover(isPresented: $showKinesteX) {
46 kinesteXKit.createChallengeView(
47 exercise: challengeExercise,
48 duration: challengeDuration,
49 showLeaderboard: showLeaderboardAfterChallenge,
50 user: nil,
51 isLoading: $isLoading,
52 customParams: ["style": "dark"],
53 onMessageReceived: { message in
54 switch message {
55 case .exit_kinestex(_):
56 showKinesteX = false
57 default:
58 print("Message received: \(message)")
59 }
60 }
61 )
62 }
63 }
64}
65
66#Preview {
67 ChallengeIntegrationView()
68}Need Help?
Our team is ready to assist with your integration.



