Skip to content

Mobile SDKs

The iOS and Android SDKs bring the website widget into your app as native screens: help-center search, requests and their replies, and live chat. They follow the widget’s settings in the admin (mode, office hours, what customers may do). Their look is set in your app’s code.

  • iOS: SwiftUI, iOS 16 or later, Swift 6, no third-party dependencies.
  • Android: Jetpack Compose (Material 3), Android 7.0 (API 24) or later, compileSdk 36.

Both use light and dark themes and speak English and Romanian.

Turn the widget on first, then open Tickets → Mobile apps and add the app with its platform and bundle id (iOS) or package name (Android). Each app gets an app key (app_…). Configure the SDK with that key and the widget id shown on the same page.

The app key is not secret: it ships inside your app and only scopes requests to that app. Removing the app in the admin is how you revoke its key.

iOS. Use Swift Package Manager. In Xcode, choose File → Add Package Dependencies… and enter https://github.com/Motenya/motenya-ios, or add it to Package.swift:

dependencies: [
.package(url: "https://github.com/Motenya/motenya-ios", from: "1.0.0"),
],
targets: [
.target(name: "YourApp", dependencies: [.product(name: "Motenya", package: "motenya-ios")]),
]

Android. The library is the :motenya Gradle module (namespace app.motenya.sdk). Until it is published, include it as a module of your build:

settings.gradle.kts
include(":motenya")
project(":motenya").projectDir = file("../motenya-android/motenya")
// app/build.gradle.kts
dependencies {
implementation(project(":motenya"))
}

Configure once, at app start.

iOS:

import Motenya
@main
struct MyApp: App {
init() {
try? Motenya.configure(widgetId: "YOUR_WIDGET_ID", appKey: "YOUR_APP_KEY")
}
}

Android:

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Motenya.configure(context = this, widgetId = "YOUR_WIDGET_ID", appKey = "app_…")
}
}

The SDKs talk to production (https://widget.motenya.app) by default. Both also accept a language. Without it, they use the first device language the knowledge base has, else the knowledge base’s default.

The accent colour is your app’s: by default the SDKs use the app’s tint (iOS) or theme colour (Android). To set another, before showing support:

Motenya.accentColor = Color("BrandBlue")
Motenya.accentColor = ContextCompat.getColor(context, R.color.brand)

A 403 means the widget id or app key is wrong, or the widget is not set up for this app. The SDK logs a warning, never the key itself.

iOS, in SwiftUI or UIKit:

.sheet(isPresented: $showsSupport) {
MotenyaSupportView(onClose: { showsSupport = false })
}
Motenya.present(from: viewController)

Android, in the library’s own activity or inside your Compose hierarchy:

Motenya.open(context)
MotenyaSupport(onClose = { showSupport = false }, entry = MotenyaEntry.Home)

Both take an entry point:

Entry Opens
Home (default) Search, “Chat with us” or “Send us a message”, and the user’s requests.
New request The request form (Tickets mode) or the chat (Chat mode).
Chat The chat (Chat mode) or the request form (Tickets mode).
Ticket, by number One of the user’s requests.

Motenya.unreadCount() returns the number of requests with a team reply the user hasn’t opened yet. Use it for a badge on your help entry.

Users are anonymous until you sign them in. Their first request or chat asks for an email, and their requests stay on that install. To show a signed-in user all of their requests, your backend signs them in with the same HS256 JWT as on the website. Use the widget’s identity secret and the same claims and rules: see Identity verification. Never put the identity secret in the app.

iOS:

try await Motenya.identify(jwt: jwtFromYourBackend)
Motenya.jwtProvider = { try await MyBackend.shared.motenyaJWT() }

Android:

Motenya.identify(jwtFromYourBackend)
Motenya.jwtProvider = { myBackend.fetchMotenyaJwt() } // return null when nobody is signed in

Set jwtProvider so the SDK can get a fresh token when the session expires or ends. The SDK then retries the failed request once. identify reports an invalid, expired, missing or mismatched identity as an error you can act on.

When the user signs out of your app, call Motenya.logout() (await it on iOS). It ends the session and forgets the anonymous visitor on the server. It then wipes the tokens, the remembered chat and downloaded attachments from the device.

Push notifications are optional. Nothing is pushed unless you turn push on for the app and the app forwards its device token. The user must also allow notifications.

In Tickets → Mobile apps, turn Push notifications on for the app and upload its credentials:

  • iOS: the APNs authentication key (the .p8 file), its key id and your team id, from your Apple developer account.
  • Android: the Firebase service account JSON of your Firebase project.

The credentials are stored encrypted and never shown again. Each app also has two more settings:

  • Show the start of the reply on the lock screen (on by default). When it’s off, the notification says only “You have a new reply”.
  • Email replies to conversations started in this app (off by default), described below.

Motenya sends a push when the team replies and the user didn’t see it live, and when a request is resolved or closed.

iOS. Add the Push Notifications capability. Then forward the token and the notification callbacks from your app delegate:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Motenya.registerDeviceToken(deviceToken)
}
nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
if await Motenya.handleNotificationResponse(response) { return } // opens support on that request
// your own notifications
}
nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
await Motenya.notificationPresentationOptions(for: notification) ?? [.banner, .sound]
}

Android. The SDK has no Firebase dependency. Set up Firebase Cloud Messaging as usual and forward the token and the data messages:

class MyMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
Motenya.registerDeviceToken(token)
}
override fun onMessageReceived(message: RemoteMessage) {
if (Motenya.handlePushMessage(this, message.data)) return
// your own messages
}
}

handlePushMessage shows the notification in a “Support replies” channel. Tapping it opens support on that request.

On both platforms:

  • registerDeviceToken is safe to call on every launch. The SDK stores the token and registers it once the user has a request, a chat or a signed-in session, and again whenever that changes. While push is off for the app, the token is kept and registered once push is turned on.
  • Motenya.isMotenyaNotification(…) tells Motenya’s notifications from your own.
  • logout() removes the device’s registration. To stop support notifications without logging out, call Motenya.unregisterDeviceToken().
  • No notification is shown while support is open on that same request.

By default, your app asks for notification permission. The SDK can offer to ask for it instead:

Motenya.pushPermissionPrompt = .afterFirstRequest // iOS; default .never
Motenya.pushPermissionPrompt = MotenyaPushPrompt.AfterFirstRequest // Android; default Never

With this option, support shows a “Get notified when we reply?” card right after the user’s first request or chat message is sent. The card appears only when push is on for the app and the user hasn’t decided yet, and at most once per install. Only Turn on shows the system prompt. The Android library declares POST_NOTIFICATIONS, which needs the user’s permission on Android 13 and later.

With Motenya.showsUnreadBadge = true, the SDK keeps the app icon badge equal to the unread count. It’s off by default, in which case the SDK never touches the badge. Android shows no badge count.

When a conversation starts in an app, users usually come back to the app for the reply. So by default, replies to these conversations are not emailed. The chat doesn’t offer “Get replies by email” and says “we’ll reply here”. Turn Email replies to conversations started in this app on in Tickets → Mobile apps to email them as well. Either way, the request form still asks an anonymous user for an email, because the email identifies them.