Onairos
  • 🔮Welcome to Onairos
  • Installation
  • API Reference
  • LLM Memory SDK
  • 🖱️Developer Guides
    • Integrate Onairos Web
      • ⬇️Installation
      • 🔅1 Line of Code
      • Manual API Call
        • 📥Receiving API
        • 🖥️Using the Inference API
      • 📲Inference API Response
      • 🏟️Examples
    • Integrate Onairos Mobile
      • ⬇️Installation
      • 🔅1 Line of Code
      • Manual API Call
        • 📥Receiving API
        • 🖥️Using the Inference API
      • 📲Inference API Response
      • 🏟️Examples
    • Example Usage of Data
    • 🚤Coming Soon
    • Developer FAQ
    • Developer Debugging
  • Overview
    • 🦄Digital Personality
    • 🔐Security and Privacy
Powered by GitBook
On this page
  • AutoFetch True:
  • AutoFetch False (Manual API Call):
  1. Developer Guides
  2. Integrate Onairos Mobile

Examples

Example Usage in a React Application

AutoFetch True:

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

class OnairosApp extends StatefulWidget {
  @override
  _OnairosAppState createState() => _OnairosAppState();
}

class _OnairosAppState extends State<OnairosApp> {
  final Map<String, dynamic> requestData = {
    "Small": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "10% Discount",
    },
    "Medium": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "2 USDC",
    },
    "Large": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "2 USDC",
    },
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Onairos Demo'),
      ),
      body: Center(
        child: OnairosButtonWrapper1(
          webpageName: 'Mobile App',
          requestData: requestData,
          returnLink: 'yourapp://returnlink',
          autoFetch: true,
          onResolved: onResolved, //Function which recieves the users Personality Data
          inferenceData: {}, // Inference data.
          proofMode: false,
          textColor: 'black', // Example color
          textLayout: 'right', // Replace with actual text layout configuration
        ),
      ),
    );
  }
}

 

AutoFetch False (Manual API Call):

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

class OnairosApp extends StatefulWidget {
  @override
  _OnairosAppState createState() => _OnairosAppState();
}

class _OnairosAppState extends State<OnairosApp> {
  Future<void> onResolved(String apiUrl, String accessToken) async {
    try {
      final response = await http.post(
        Uri.parse(apiUrl),
        headers: {
          "Authorization": "Bearer $accessToken",
          "Content-Type": "application/json",
        },
        body: jsonEncode(requestData),
      );

      if (response.statusCode == 200) {
        final Map<String, dynamic> data = jsonDecode(response.body);
        // Process Onairos Data
        print("Data: $data");
      } else {
        // Handle error response
        print("Error: ${response.statusCode}");
      }
    } catch (e) {
      print("Exception: $e");
    }
  }

  final Map<String, dynamic> requestData = {
    "Small": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "10% Discount",
    },
    "Medium": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "2 USDC",
    },
    "Large": {
      "type": "Personality",
      "descriptions": "Insight into your Interests",
      "reward": "2 USDC",
    },
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Onairos Demo'),
      ),
      body: Center(
        child: OnairosButtonWrapper1(
          webpageName: 'Mobile App',
          requestData: requestData,
          returnLink: 'yourapp://returnlink',
          autoFetch: true,
          onResolved: onResolved,
          inferenceData: {}, // Assuming this is a placeholder or real data.
          proofMode: false,
          textColor: Colors.black, // Example color
          textLayout: TextLayout(), // Replace with actual text layout configuration
        ),
      ),
    );
  }
}
PreviousInference API ResponseNextExample Usage of Data

Last updated 9 months ago

🖱️
🏟️