Aller au contenu principal

⚙️ Initialisation du SDK

Toutes les plateformes utilisent le même cycle de vie :

  1. initialize — Clé API + config optionnelle. Aucun utilisateur.
  2. connect — JWT utilisateur + genre + taille + poids. Voir Authentification.
Checklist complète

Noms d'API par plateforme

PlateformeInitializeConnect
FlutterAzeooSDK.initializeAzeooSDK.connect
AndroidAzeooSDK.initializeAzeooSDK.shared.connectUser
iOSAzeooSDK.initializesdk.connectUser
React NativeAzeooSDK.initializeconnect sur le wrapper SDK

Étape 1 : Initialize

Flutter

import 'package:azeoo_sdk/azeoo_sdk.dart';

await AzeooSDK.initialize(
'your-api-key',
options: AzeooSDKInitOptions(
locale: 'en',
analyticsEnabled: true,
offlineSupport: true,
theme: themeConfig, // optional
deepLinks: deepLinkConfig, // optional
safeArea: SafeAreaConfig.all(),
connector: connectorConfig, // optional — see Connectors
),
);

Android

import com.azeoo.sdk.AzeooSDK
import com.azeoo.sdk.AzeooConfig

AzeooSDK.initialize(
context = applicationContext,
apiKey = "your-api-key",
config = AzeooConfig(
locale = "en",
analyticsEnabled = true,
offlineEnabled = true,
connectionTimeoutSeconds = 30L,
persistSession = true,
),
theme = themeConfig, // optional
deepLinks = deepLinkConfig, // optional
safeArea = safeAreaConfig, // optional
) { error ->
if (error != null) { /* handle */ return@initialize }
// Ready for connect — use AzeooSDK.shared
}

iOS

import AzeooSDK

let config = AzeooConfig(
locale: "en",
analyticsEnabled: true,
offlineEnabled: true,
connectionTimeoutSeconds: 30,
persistSession: true
)

AzeooSDK.initialize(
apiKey: "your-api-key",
config: config,
theme: themeConfig,
deepLinks: deepLinkConfig,
safeArea: safeAreaConfig
) { result in
switch result {
case .success:
let sdk = AzeooSDK.shared
// Ready for connectUser
case .failure(let error):
break
}
}

React Native

import { AzeooSDK } from 'react-native-azeoo-lib';

await AzeooSDK.initialize('your-api-key', {
locale: 'en',
analyticsEnabled: true,
offlineEnabled: true,
// theme, deepLinks, safeArea optional
});

Étape 2 : Connecter l'utilisateur

Vous avez besoin d'un JWT depuis votre backend et des champs de profil de l'utilisateur.

Flutter

await AzeooSDK.connect(
token: userJwt,
gender: 'male', // or your app's gender value
height: Height.scalar(180, HeightUnit.centimeters),
weight: Weight.scalar(75, WeightUnit.kilograms),
);
// userId available: AzeooSDK.userId

Android

AzeooSDK.shared.connectUser(
token = userJwt,
gender = user.gender,
height = user.height, // AzeooHeight
weight = user.weight, // AzeooWeight
) { profile, error ->
if (error != null) return@connectUser
val userId = profile?.id
}

iOS

AzeooSDK.shared.connectUser(
token: userJwt,
gender: user.gender,
height: user.height,
weight: user.weight
) { result in
// profile contains user id
}

React Native

await AzeooSDK.connect(userJwt, gender, heightValue, weightValue);
// See platform doc for measurement shape

Voir Mesures pour les unités taille/poids.


Déconnexion

Efface la session utilisateur. Le SDK reste initialisé.

PlateformeAPI
Flutterawait AzeooSDK.disconnect()
AndroidAzeooSDK.shared.disconnect { }
iOSAzeooSDK.shared.disconnect { }
React Nativeawait AzeooSDK.disconnect()

Prochaines étapes