With TeamViewer Software Development Kit (SDK) you can utilize full Assist AR functionality and provide the best AR remote support experience to your customers by embedding AR remote assistance capabilities within your own mobile apps.
The SDK enables you to have secure and GDPR compliant connections to your customer's devices.
This article applies to all TeamViewer Assist AR users.
If you don't have a TeamViewer account, follow the steps below to create one:
1) Go to https://login.teamviewer.com/ and sign in using your TeamViewer account.
2) On the bottom of the page, click Apps.
3) Click the Create App button.
4) Activate Mobile SDK Token, enter a name, and (optional) add a short description.
5) Activate Android.
6) Click Create.
Your token is displayed when opening the created app:
Copy this token into your clipboard and paste it to a secure place.
🚨IMPORTANT: Do not share this token with anyone!
SDK is available for customers with an Assist AR Professional license and is distributed by the TeamViewer Support team.
Integrate Your TeamViewer Mobile SDK
1) TeamViewer Mobile SDK for Android contains below files:
2) Create a libs folder under your app directory and copy the *.aar files there.
📌Note: The SDK supports the following architectures: armeabi-v7a, arm64-v8a, x86, x86_64.
3) Enable ViewBinding and add following dependencies to your app’s build.gradle:
android { buildFeatures { viewBinding true } } dependencies { implementation files('libs/TeamViewerSdk.aar') implementation files('libs/AssistARSessionUI.aar') //(Add only if you plan to use AssistAR(AssistAR) Session // Add dependencies of AssistARSessionUI.aar(Add only if you plan to use AssistAR Session): runtimeOnly "androidx.camera:camera-camera2:1.0.2" runtimeOnly "androidx.camera:camera-lifecycle:1.0.2" runtimeOnly "androidx.constraintlayout:constraintlayout:2.0.4" runtimeOnly "androidx.fragment:fragment-ktx:1.3.6" runtimeOnly "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1" runtimeOnly "androidx.work:work-runtime-ktx:2.5.0" runtimeOnly "com.google.android.material:material:1.4.0" runtimeOnly "de.javagl:obj:0.3.0" runtimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31" runtimeOnly "com.google.android.gms:play-services-mlkit-text-recognition:17.0.0" runtimeOnly "com.squareup.picasso:picasso:2.8" }
To get an updated list of dependencies please check AssistARSessionUI-docs/index.html which will be part of the SDK package you receive from TeamViewer.
4) Build the TeamViewerSdk object:
teamViewerSdk = TeamViewerSdk.Builder(context) .withToken(SDK_TOKEN) .withAuthenticationCallback(sdkAuthenticationCallback) .withSessionCallback(sdkSessionCallback) .withErrorCallback(sdkErrorCallback) .withOnlineStateCallback(onlineStateCallback) .withMicInitiallyMuted(true) .build() }
The above example shows the creation teamViewerSdk object using SDK_TOKEN (use SDK_TOKEN created above in step 7 of “Generate API Key Section”)
Please visit ScreenSharingSdk-docs/com/teamviewer/sdk/screensharing/TeamViewerSdk.Builder.html to learn more details about these builder methods. The documentation will be part of SDK package you receive from TeamViewer.
5) Connect to a session code
The shared SDK provides a method for establishing a connection to a session code. This session code can be of two types:
6) Create session codes in your TeamViewer Client (select the type Remote Support or AssistAR based on the session you want) or via the TeamViewer REST API.
teamViewerSdk.connectToSessionCode(sessionCode)
Once sessionCode is online, a connection can be initiated from TeamViewer Client side.
The session code state can be checked using OnlineStateCallback
(ScreenSharingSdk-docs/com/teamviewer/sdk/screensharing/TeamViewerSdk.Builder.html#withOnlineStateCallback
(com.teamviewer.sdk.screensharing.OnlineStateCallback).
OnlineStateCallback is useful to get notified of the SDK online/offline/connected state:
private val onlineStateCallback = OnlineStateCallback { onlineState -> val isSdkOnline = OnlineStateCallback.OnlineState.OFFLINE val isSdkOffline = OnlineStateCallback.OnlineState.ONLINE val isSessionCodeConnected = OnlineStateCallback.OnlineState.CONNECTED }
ErrorCallback is useful to handle error codes sent by the SDK in case the session code is invalid, expired, or closed.
(ScreenSharingSdk-docs/com/teamviewer/sdk/screensharing/TeamViewerSdk.Builder.html#withErrorCallback
(com.teamviewer.sdk.screensharing.ErrorCallback))
private val sdkErrorCallback = ErrorCallback { errorCode -> val invalid = errorCode == ErrorCallback.ErrorCode.SESSION_CODE_INVALID val expired = errorCode == ErrorCallback.ErrorCode.SESSION_CODE_EXPIRED val closed = errorCode == ErrorCallback.ErrorCode.SESSION_CODE_CLOSED }
The SDK provides callback methods for reacting to incoming connection events.
AuthenticationCallback is useful to handle incoming connections.
AuthenticationData parameter contains the name of the supporter and a callback function to allow or reject the incoming connection.
private val sdkAuthenticationCallback = object : AuthenticationCallback { override fun onAuthentication(data: AuthenticationData?) { //set true to accept call, set false to reject call data?.callback?.onAuthenticationResult(true) Logging.info(TAG, "TeamViewer connected to ${data?.partnerName}") } override fun onAuthenticationCanceled() { // Is called when TeamViewer Authentication was cancelled from TeamViewer client/expert side } }
If the incoming connection is accepted, the corresponding TeamViewer connection is established.
Once the connection is initiated on the TeamViewer side, the SDK gets notified about this connection attempt via SessionCallback.
I) AssistARSession(AssistARSession):
For AssistAR sessions make sure to ->
private val sdkSessionCallback = object : SessionCallback { override fun onSessionStarted(session: TeamViewerSession?) { if (session is AssistARSession) { AssistARSessionUI.currentSession = session val intent = AssistARSessionUI.createIntentForAssistARSessionActivity(context, "StorageFolderName") intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK context.startActivity(intent) } if (session is ScreenSharingSession) { //Request microphone permission if you intend to use VOIP with ScreenShare Session } } override fun onSessionEnded() { Logging.info(TAG, "TeamViewer Session ended") AssistARSessionUI.currentSession = null } }
Passing storageFolderName to the createIntentForAssistARSessionActivity method here is mandatory as this is the name of the folder where shared documents will be stored under the Downloads folder. For details check out AssistARSessionUI-docs/-pilot-session-u-i/com.teamviewer.sdk.assistarsessionui/-assist-a-r-session-u-i/create-intent-for-assist-a-r-session-activity.html
II) ScreenSharingSession:
ScreenSharingSession requires to request the microphone permission in OnSessionStarted() if you intend to use VOIP.
Logging:
Builder method withLogger(Logger callback) sets a Logger callback to which all log output from the TeamViewer Sdk is delegated to.
To check out details for this callback and other additional callbacks available with Sdk builder please visit ScreenSharingSdk-docs/com/teamviewer/sdk/screensharing/TeamViewerSdk.Builder.html.