Connect.ai
  • Overview
  • Architecture
  • SDK Integration Guides
    • Swift (iOS)
    • Python
    • Javascript
    • Rust
    • SDK Troubleshooting
  • Features
    • User Authentication
    • Paywall Management
  • Getting Started
    • Developer Portal Overview
    • Signing Up
    • Creating an App
    • App Submission Guidelines
  • Join Our Discord
Powered by GitBook
On this page
  • Installation
  • Usage
  • User Authentication
  • Analytics Tracking
  1. SDK Integration Guides

Rust

Installation

To add the Connect Framework Rust SDK to your project, include it in Cargo.toml:

[dependencies]
connect-framework = "0.8"

Then, import the crate in your code:

use connect_framework::ConnectFramework;

Usage

Initializing the SDK

Before making any API calls, you must initialize the SDK with your API key.

// Initialize the SDK with an API key
ConnectFramework::initialize("your_api_key_here");

User Authentication

Logging in with a Unique ID and Email

Logs in the user using a unique ID and an email. If unique_id is None, a new one will be generated automatically. The callback is executed when the login process completes.

ConnectFramework::login(None, "user@example.com");

Submitting an OTP Code

If the login process requires an OTP (One-Time Password), this function submits the OTP code for verification.

fn otp_callback(success: bool) {
    if success {
        println!("OTP verified successfully and logged in.");
    } else {
        println!("OTP verification failed.");
    }
}

ConnectFramework::submit_otp("user@example.com", "123456", otp_callback);

Logging Out

Logs out the user entirely.

ConnectFramework::logout();

Checking if User is Connected

Returns true if the user is logged in and running the Connect.ai desktop client.

let is_connected = ConnectFramework::is_connected();
println!("User is connected: {}", is_connected);

Analytics Tracking

Logging an Event

Logs an analytics event with a category and action.

ConnectFramework::log_event("user_action", "button_click");

Logging an Event with Additional Data

Logs an analytics event with a category, action, label, and numerical value.

ConnectFramework::log_event_with_details("user_action", "purchase", "premium_upgrade", 29.99);
PreviousJavascriptNextSDK Troubleshooting

Last updated 2 months ago