- iOS: iOS 14.0 or higher
Add the following keys for camera usage:
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
Add the JitPack repository to your project’s settings.gradle
or build.gradle
(if settings.gradle
is not your primary dependency resolution file):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add the KinesteX SDK dependency in your app’s build.gradle
:
implementation("com.github.KinesteX:KinesteXSDKKotlin:1.2.0")
Before a user starts a workout, we need to get access to camera (if your app doesn't have access to camera already). We are requesting camera permission on the app level and need to handle the result in the app level as well.
-
Make sure your activity or fragment where you are presenting KinesteX views implements the
PermissionHandler
interface:class MainActivity : AppCompatActivity(), PermissionHandler
-
Create necessary variables and override the
requestCameraPermission
method inPermissionHandler
interface:
// initialize the webview
private var kinesteXWebView: GenericWebView? = null
private var apiKey = yourApiKey // can be generated in admin dashboard
private var companyName = yourCompanyName // also can be found in admin dashboard
private var userId = yourUserId // can be any String, must be unique for each user
// OPTIONAL:
// If available, you can pass user details to automatically adjust some exercises and correctly estimate calories based on the user's information.
// Note: User details are only used on the device for customization purposes during the session. If you want to persist the customization across sessions, you'll need to pass the customization data everytime when launching KinesteX.
private var userDetails = UserDetails(age = 20, height = 170, weight = 180, gender = Gender.MALE, lifestyle = Lifestyle.ACTIVE)
// request camera permission
private val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted: Boolean ->
// pass permission result to KinesteX webview
kinestexWebView?.handlePermissionResult(isGranted)
}
// when request is sent, display system dialog for camera access
override fun requestCameraPermission() {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
The SDK sends various messages. Implement a callback to handle these messages:
private fun handleWebViewMessage(message: WebViewMessage) {
when (message) {
is WebViewMessage.ExitKinestex -> {
// dismiss KinesteX view since user is clicking on exit button inside the view
}
// handle other messages
else -> {
Log.d("Message received", message.toString())
}
}
}