Check session
After a successful sign-in, AuthlyX needs to check that access is still valid. A heartbeat is that repeated check while the app is running. In the default server mode, the SDK does it for you using the interval sent by AuthlyX. Most apps should keep this default.
checkSession is one check you can call yourself. Use it when your app returns from sleep, a long pause or a suspended mobile/desktop state. Do not call checkSession every few seconds when automatic heartbeat is already enabled.
Check again after the app wakes
onResume means “the app is active again, check access now.” It performs the same server check as checkSession. It does not start a new session or extend an expired one. Call it once when your app resumes after being asleep or suspended. The SDK also checks again on its normal heartbeat schedule. Some languages use their normal naming style, such as onResume in Python and Rust.
Default mode and manual mode
- Server mode is the default. The SDK starts periodic checks after sign-in and handles session invalidation. Use this unless you have a reason to control scheduling yourself.
- Manual mode turns off the automatic timer. Your app must call
checkSessionwhile it is active andonResumewhen it wakes. If you forget to call them, the app may keep showing protected screens until another request reaches AuthlyX.
The default is server, so most apps do not need to set this option. In this mode, the SDK starts its own timer after a successful sign-in and checks again at the interval returned by AuthlyX. If your app will manage the schedule itself, choose manual when creating the SDK instance:
These are construction examples only. Keep the normal AppKey, version, storage and trusted public keys in the SDK options. If you do not already have a reason to control the schedule, leave the setting alone.
When access ends
In server mode, you do not need to call checkSession on a timer. The SDK checks in the background. When AuthlyX confirms that the session has expired, was ended, or the identity is paused or banned, the SDK clears its signed-in state and calls the invalidation handler. Use that handler to hide protected screens and show your sign-in screen. The SDK does not close your app.
Each language names that handler differently. Set it when creating the SDK, except C#, where it is an event on the app object:
These handlers print the reason so the example works in a console. In a real app, replace the print call with your own code to show the sign-in screen. The SDK does not close your app. See the language tabs below for checking a session yourself.
A timeout is different from an expired session: the server did not answer, so the SDK cannot confirm that access ended. Show a connection problem and keep protected actions unavailable until access is confirmed again.
SDK version: V3 Beta. These examples use the current downloads. For what the callback, future, await, CompletableFuture and Go err mean, read Results.
C#
C++
Python
JavaScript / Node.js
TypeScript
Java
Go
Rust
checkSession accepts a callback. onResume() returns a Task, so call it with await inside an async method. Call CheckAfterResume() from the event your framework raises when the app wakes. This SDK method does not have a callback overload for onResume.
The code above prints a simple message to keep the example short. In a real app, disable paid or protected actions when access is not confirmed, keep unrelated work available, and show your own sign-in or connection screen.

