Social+ Docs
About UsDeveloper PortalArchives
  • Social+
  • Announcements
  • Technical FAQ
  • Getting Started
    • Installation and Authentication
      • Install iOS SDK
      • Install Android SDK
      • Install JavaScript SDK (Deprecated)
      • Install TypeScript SDK
      • Install Flutter SDK
      • Install SDK for Ionic
    • Tutorials
  • Social+ SDK
    • Core Concepts
      • Session State
      • User
        • Create User
        • Get User Information
        • Search and Query Users
        • Update User Information
        • Delete User
        • Roles & Permissions
        • User Token Management
        • Flag / Unflag User
      • Files, Images, and Videos
        • File Handling
        • Image Handling
        • Video Handling
      • Push Notifications
        • iOS Push Notification Certificate Setup
        • Android Push Notifications Initialization
        • React Native Push Notifications Initialization
        • Register and Unregister Push Notifications on a Device
        • Push Notification Toggles
          • User Push Notification Settings
          • Channel Push Notification Settings
          • Community Push Notification Settings
      • Mentions
      • Poll
      • Ads
        • Get Ads and Settings
        • Ad Impressions
      • Presence State
        • Heartbeat Sync
        • User Presence
        • Channel Presence
      • Live Objects/Collections
        • iOS Live Objects/Collections
        • Android Live Objects/Collections
        • Javascript Live Objects/Collections
        • TypeScript Live Objects/Collections
        • Flutter Live Objects/Collections
      • Realtime Events
        • Social Realtime Events
        • Chat Realtime Events
      • Error Handling
      • Content Moderation
      • Logging
    • Chat
      • Channels
        • Create Channel
        • Query Channels
        • Get Channel
        • Get Channels
        • Update Channel
        • Join/Leave Channel
        • Subchannel
        • Message Preview
        • Unread Count
          • Channel Unread Count
          • Start / stop message read receipt sync
          • Mark Message as Read
          • Message Delivery Status
          • Observe reading count
        • Read Status & Unread Count (Legacy)
        • Channel Moderation
        • Query Members
        • Search Members
        • Archive Channels
      • Messaging
        • Send a Message
          • Text Message
          • Image Message
          • Audio Message
          • Video Message
          • File Message
          • Custom Message
          • Reply to a Message
        • Query and Filter Messages
        • Get and View a Message
        • Edit and Delete Messages
        • Message Reaction
        • Mention in Messages
        • Flag/Unflag a Message
      • Moderation
        • Roles and Permission
        • Mute/Unmute a List of Channel Members
        • Ban/Unban a List of Channel Members
        • Channel Rate-Limiting
    • Social
      • Posts
        • Create Post
          • Text Post
          • Image Post
          • File Post
          • Video Post
          • Live stream Post
          • Poll Post
          • Custom Post
        • Query Post
        • Get Post
        • Viewing Post Content
        • Edit Post
        • Delete Post
        • Mention in Post
        • Flag / Unflag Post
        • Post Review
        • Post Impression
        • Pinned Post
      • Stories
        • Get Global Story Targets
        • Create Story
        • Get Stories
        • Delete Story
        • Get Story Targets
        • Story Impressions
      • Comments
        • Create Comment
        • Query Comment
        • View Comment
        • Get Comment
        • Get Latest Comment
        • Edit Comment
        • Delete Comment
        • Flag/Unflag
        • Get Comment Reaction Data
        • Mention in Comment
      • Reactions
        • Query Reactions
        • Add / Remove Reaction
      • Feed
        • Custom Post Ranking
        • Query Global Feed
      • Communities
        • Create Community
        • Get Community
        • Query Communities
        • Update Community
        • Delete Community
        • Join/Leave Community
        • Trending and Recommended Communities
        • Query Community Members
        • Community Moderation
        • Community Categories
      • Follow/Unfollow
        • Get Connection Status and Connection Counter
        • Follow/Unfollow User
        • Get Follower/Following List
        • Accept/Decline Follow Request
      • Block and Unblock User
      • Intelligent Search
        • Intelligent Search - Post
        • Intelligent Search - Community
      • Notification tray
        • Get Notification Tray Seen
        • Mark Notification Tray Seen
        • Query Notification Tray Item
        • Mark Notification Tray Item Seen
    • Video
      • iOS
        • View & Play Live Stream
        • Broadcast Live Stream
        • Push Notifications
      • Android
        • View & Play Live Stream
        • Broadcast Live Stream
        • Push Notifications
      • Flutter
        • View & Play Live Stream
        • Push Notifications
      • Web
        • View & Play Live Stream
        • Create Live Stream
        • Push Notifications
      • TypeScript (Beta)
        • RunQuery Pattern
        • Live Stream
      • React Native
        • View & Play Live Stream
        • Broadcast Live Stream
    • Changelogs & Versioning
      • iOS
      • Android
      • TypeScript
      • React Native
      • Flutter (Beta)
      • React Native (Video)
      • JavaScript (Deprecated)
  • Social+ UIKit
    • UIKit 4
      • Installation Guide
        • iOS
        • Android
        • Web React
        • Flutter (Beta)
        • React Native (Beta)
      • Setup and Authentication
        • iOS
        • Android
        • Web React
        • Flutter (Beta)
        • React Native (Beta)
      • Customization
        • Remote Config (Beta)
        • Customization Basics
        • Overriding Navigation Behaviour
      • Social
        • Discover & Search
          • Social Home Page
            • Top Navigation Component
            • Newsfeed Component
            • Empty Newsfeed Component
            • Global Feed Component
            • Create Post Menu Component
            • Community Categories Component
            • Recommended Communities Component
            • Trending Communities Component
          • Global Search Page
            • Top Search Bar Component
            • Community Search Result Component
            • User Search Result Component
          • My Communities Search Page
          • All Categories Page
          • Communities By Category Page
          • Notification Tray
        • Community
          • Community Setup Page
            • Add Category Page
            • Add Member Page
          • Community Profile Page
            • Community Header Component
            • Community Feed Component
            • Community Pin Feed Component
            • Community Image Feed Component
            • Community Video Feed Component
          • Pending Post Page
            • Pending Post Content Component
          • Community Setting Page
            • Community Notification Setting Page
              • Community Posts Notification Page
              • Community Comments Notification Page
              • Community Stories Notification Page
            • Community Post Permissions Page
            • Community Story Setting Page
          • Community Membership Page
        • User
          • User Profile Page
            • User Profile Header Component
            • User Feed Component
            • User Image Feed Component
            • User Video Feed Component
          • Edit User Profile Page
          • Blocked User Page
          • User Relationship Page
          • User Pending Follow Request Page
        • Post
          • Post Details Page
            • Post Content Component
          • Post Composer Page
            • Media Attachment Component
            • Detailed Media Attachment Component
          • Post Target Selection Page
          • Poll Post Composer Page
          • Poll Target Selection Page
        • Livestream
          • Livestream Target Selection Page
          • Livestream Creation Page
          • Livestream Player Page
          • Livestream Terminated Page
        • Story
          • Story Target Tab Component
          • Story Creation Page
            • Story Drafting Page
          • Story Viewing Page
          • Story Target Selection Page
        • Comment & Reaction
          • Comment Tray Component
          • Reaction List Component
        • Content moderation
      • Chat
        • Recent chats (channel list)
          • Chat Home Page
          • Chat List Component
          • Archived Chat List Component
          • Amity Channel Create Conversation Page
        • Conversation Chat
          • AmityChatPage
          • AmityMessageComposer
        • Live Chat
          • Live Chat Page
            • Live Chat Header Component
            • Live Chat Message List Component
              • Reaction List Component
            • Live Chat Compose Bar Component
    • UIKit 3
      • iOS (Deprecated)
        • Overview
        • iOS UIKit Installation Guide
        • Installing UIKit (deprecated)
        • Setup & Authentication
        • Using Themes
        • Social UIKit
          • Using as a whole feature with the default settings
          • Our Components
            • Community Home Page
              • Newsfeed
                • Global Feed
                • My Community Preview
              • Explore Tab
                • Recommended Community
                • Top Trending
                • Categories
            • My Community Page
            • Category List Page
            • Community List by Category Page
            • Community Creation Page
            • Community Profile Edit Page
            • Community Setting Page
              • Community Push Notification Settings Page
                • Community Push Notification Settings - Comment and Reply Relate Event Page
                • Community Push Notification Settings - Post Relate Event Page
            • Post Creation Page
              • Livestream Post
            • Post Detail Page
            • Post Edit Page
            • Comment Creation
            • Comment Edit Page
            • Community Profile Page
              • Community Feed
              • Media Gallery
            • Community Member Page
            • User Profile Page
              • User Feed
            • User Profile Page (2.2)
              • User Feed (2.2)
            • User Setting Page(2.2)
            • User Profile Edit Page
            • Following / Follower User List Page (2.2)
            • Follow Request Page (2.2)
            • Member Selection Page
            • Post Target Selection Page
          • Using Your Own Component
            • Using Your Own Navigation Bar
          • Overriding UIKit Behaviour
            • Feed UI Settings
              • Post Sharing
              • Post Rendering
            • Event Handling
              • Example
          • Roles & Permissions
        • Chat UIKit
          • Using as a Whole Feature with the Default Settings
          • Using Only Some Components
            • Chat Home Page
              • Recent chat
            • Chat Room Page
          • Using your own component
            • Message Bubble
        • Video UIKit
          • Livestream
      • Android (Deprecated)
        • Overview
        • Android UIKit Installation Guide
        • Installing UIKit (deprecated)
        • Setup & Authentication
        • Using Themes
        • Social UIKit
          • Using as a whole feature with the default settings
          • Our Components
            • Community Home Page
              • Newsfeed
                • Global Feed
                • My Community Preview
              • Explore Tab
                • Recommended Community
                • Top Trending Community
                • Categories
            • My Community Page
            • Category List Page
            • Community List By Category Page
            • Community Creation Page
            • Community Profile Edit Page
            • Post Creation Page
              • Livestream Post
            • Post Details Page
            • Post Edit Page
            • Comment Creation
            • Comment Edit Page
            • Community Profile Page (2.5)
              • Community Feed (2.5)
              • Media Gallery
            • Community Member Page
            • User Profile Page
              • User Feed
            • User Profile Page (2.3)
              • User Feed (2.3)
            • User Setting Page (2.3)
            • Following and Follower User List Page(2.3)
            • Follow Request Page (2.3)
            • User Profile Edit Page
            • Member Selection Page
            • Post Target Selection Page
          • Using Your Own Components
            • Using Your Own Navigation Bar
          • Overriding UIKit Behaviour
            • Overriding Global Behaviour
              • Feed UI Settings
                • Post Sharing
                • Post Rendering
            • Event Handling
              • Example
        • Chat UIKit
          • Using as a whole feature with the default settings
          • Using Only Some Components
            • Chat Home Page
              • Recent Chat
            • Chatroom Page
          • Using Your Own Component
            • Message Bubble
      • React (Deprecated)
        • Overview
        • Web UIKit Installation Guide
        • Installing UI Kit (deprecated)
        • Setup & Authentication
        • Using Themes
        • Social UIKit
          • Using as a whole feature with the default settings
          • Our Components
            • Community Home Page
              • Search Communities
              • Newsfeed
                • Global Feed
              • Explore
                • Recommended Communities
                • Top Trending Communities
                • Categories
            • My Community
            • Community List By Category Page
            • Community Creation Page
            • Community Settings
              • Edit Profile Page
              • Members
              • Permissions
            • Post Creation
              • Livestream Post
            • Post Edit
            • Comments
            • Community Profile Page
              • Community Feed
              • Media Gallery
              • Community Members Page
              • Transfer Moderator Role
            • User Profile
              • User Feed
              • Media Gallery
              • Following / Follower User List Page
            • Follow Request Page
            • Profile Settings Page
          • Using Your Own Component
            • Using Your Own Like Button for Posts
          • Overriding UIKit Behaviour
            • Post Rendering
        • Chat UIKit
          • Using as a Whole Feature with the Default Settings
          • Our Components
            • Recent Chat
            • Chat Room
            • Message Bubble
            • Chat Details
        • Event Handling
          • Example
        • Roles & Permissions
      • Flutter (Beta)
        • Overview
        • Flutter UIKit Installation Guide
        • Setup & Authentication
        • Using Themes
        • Social UIKit
          • Using as a whole feature with the default settings
      • React Native (Beta)
        • Setup & Authentication
        • Running the Sample App with Expo
    • Changelogs
      • iOS
      • Android
      • Flutter
      • Web (React)
      • React Native
        • React Native Chat UIKit
        • React Native Social UIKit
  • Analytics & Moderation
    • Social+ Portal
      • Getting Started
      • Application Management
      • Account Management
      • Dashboard
        • Raw Data Export
      • Changelogs
    • Social+ Console
      • Moderation, Roles & Privileges
      • Chat Management
        • Channel Management
        • Message Management
        • Chat Activities (Beta)
      • Social Management
        • Communities
        • Posts
          • Post Viewing and Management
          • Post Creation
          • Post Pinning and Featuring
        • Comments
          • Comment Viewing and Management
          • Comment Creation and Reply
        • Stories
      • User & Content Management
        • User Social History
      • Admin Access Control
      • Livestream Moderation
      • Premium Ads
        • Setting Up Premium Ads
        • Setting Up Advertiser Profile
      • Settings
        • Image Moderation
        • Push Notifications
        • Security
          • Admin Token Management
        • Brand Settings
      • AI Content Moderation
      • Changelogs
    • Social+ APIs and Services
      • Network Settings
      • Generate User Last Activity Report
      • Pre-Hook Event
  • Developers
    • Developer Kits
    • Beta Features
      • Enhance Moderation
      • Search Posts API
      • Content Search V2 (Deprecated)
      • Webhook Events
      • Notification Tray
      • Block User
      • User Activity
    • Migration Guides
      • FCM legacy API Migration Guide
      • SDK v6.26.0 Unread Count Migration Guide
      • JS SDK to TS SDK Migration Guide
      • Web UIKit v3.0 Migration Guide
      • iOS UIKit V3.0 Migration Guide
      • iOS SDK v7.0.0 Migration Guide
      • iOS SDK v6.0.0 Migration Guide
        • iOS SDK v6.9.0 Deprecation Note
        • iOS SDK v6.8.0 Deprecation Note
        • iOS SDK v6.7.0 Deprecation Note
        • iOS SDK v6.5.0 Deprecation Note
      • Android SDK v7.0.0 Migration Guide
      • Android SDK v6.0.0 Migration Guide
        • Android SDK v.6.20.0 Deprecation Note
        • Android SDK v.6.19.0 Deprecation Note
        • Android SDK v6.10.0 Deprecation Note
        • Android SDK v6.9.0 Deprecation Note
        • Android SDK v6.5.0 Deprecation Note
      • TS SDK v7.0.0 Migration Guide
      • TS SDK v6.0.0 Migration Guide
        • TS SDK v6.4.6 Deprecation Note
        • TS SDK v6.8.0 Deprecation Note
      • Web SDK v5.0.0 Migration Guide
      • Flutter SDK v7.0.0 Migration Guide
      • Flutter SDK beta Migration Guide
        • Flutter SDK v0.21.0 Deprecation Note
    • SDK API Reference
      • Server API Reference
      • iOS SDK API Reference (beta)
      • Android SDK API Reference (beta)
      • Flutter SDK API Reference
  • Miscellaneous
    • Support
      • Code of conduct
      • Managed UI Kit - Deprecation
      • Contribute
      • Security
    • Announcements Archive
Powered by GitBook
On this page
  • Adding required permissions
  • Setup API key
  • Step 1: Initialize Social Plus SDK
  • Step 2: Wrap MaterialApp with AmitySLEProvider
  • Step 3: Implement Authentication
  • Step 4: Navigating to UIKit Screens
  • Final Step: Running Your App
  • Register the device for push notifications
  • Unregister

Was this helpful?

Export as PDF
  1. Social+ UIKit
  2. UIKit 3
  3. Flutter (Beta)

Setup & Authentication

With Social Plus UIKit 2.3, we have introduced a new way to Authentication process. Just follow the guide below.

Last updated 5 months ago

Was this helpful?

Adding required permissions

Your app may require the following permissions to work properly;

  1. Camera access

  2. Microphone access

  3. Photo library usage access

Before submitting your application to the store, please make sure the following permissions are already granted. Here are the steps to ask for permission.

Locate the info.plist file and add:

  1. NSCameraUsageDescription

  2. NSMicrophoneUsageDescription

  3. NSPhotoLibraryUsageDescription

Setup API key

AmityUIKit requires an API key. You need a valid API key to begin using the UIKit. Please find your account API key in the

After logging in Console:

  1. Click Settings to expand the menu.

  2. Select Security.

  3. On the Security page, you can find the API key in the Keys section.

Certainly! The provided code snippet demonstrates how to set up and authenticate using the Social Plus UIKit for Flutter. Let's break it down into a step-by-step guide:

Step 1: Initialize Social Plus SDK

First, you need to initialize the Social Plus SDK in your main function. This is crucial for setting up the SDK before your Flutter app starts running.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  AmitySLEUIKit().initUIKit("YOUR_API_KEY", "REGION");
  runApp(const MyApp());
}
  • WidgetsFlutterBinding.ensureInitialized(): Ensures that Flutter bindings are initialized.

  • AmitySLEUIKit().initUIKit("YOUR_API_KEY", "REGION"): Initializes the Social Plus UIKit with your API key and region. Replace "YOUR_API_KEY" and "REGION" with the actual values.

Step 2: Wrap MaterialApp with AmitySLEProvider

In your main app widget (here, MyApp), wrap the MaterialApp with AmitySLEProvider. This provider is necessary for the Amity UIKit to function properly throughout your app.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AmitySLEProvider(
      child: Builder(builder: (context2) {
        // Configuration and MaterialApp code goes here
      }),
    );
  }
}

Step 3: Implement Authentication

In your InitialWidget class, implement a button to handle the login process with Social Plus.

ElevatedButton(
  onPressed: () {
    AmitySLEUIKit().registerDevice(context, "USER_IDENTIFIER");
  },
  child: const Text("Login to Amity"),
),
  • Replace "USER_IDENTIFIER" with the identifier of the user who is logging in.

Step 4: Navigating to UIKit Screens

The code provides examples of how to navigate to various screens provided by the Social Plus UIKit, like channel lists, chat rooms, and global feeds.

Navigator.of(context).push(MaterialPageRoute(
  builder: (context) => const CommunityPage(),
));

Final Step: Running Your App

Once these steps are implemented, you can run your Flutter app. The Social Plus UIKit should be integrated and functioning according to the setup in your main.dart.

Remember to replace placeholders like "YOUR_API_KEY", "REGION", and "USER_IDENTIFIER" with actual values specific to your Social Plus UIKit setup.

Register the device for push notifications

Registering your app for push notifications will require a device token as a parameter.

Social Plus's UIKit does not manage:

  • User-facing requests for push notifications and authorizations

  • The creation and refreshing of push notification tokens

It's up to your app to take those steps and pass the device token.

AmitySLEUIKit().registerNotification("asdasdasdasd",(isSuccess, error) {});

Unregister

If your user logs out, you should explicitly unregister the user from the SDK as well, to prevent the current device from receiving any unnecessary or restricted data.

AmitySLEUIKit().unRegisterDevice();

Unregistering a device is a synchronous operation. Once theunregisterDevice method is called, the SDK disconnects from the server and wipes out user session.

Example main.dart

import 'package:amity_uikit_beta_service/amity_sle_uikit.dart';
import 'package:amity_uikit_beta_service/components/alert_dialog.dart';

import 'package:amity_uikit_beta_service/view/UIKit/social/my_community_feed.dart';

import 'package:amity_uikit_beta_service/view/social/global_feed.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/create_community_page.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/explore_page.dart';
import 'package:amity_uikit_beta_service/view/UIKit/social/post_target_page.dart';

void main() {
  ///Step 1: Initialize amity SDK with the following function
  WidgetsFlutterBinding.ensureInitialized();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final TextEditingController _apiKey = TextEditingController();
  AmityRegion? _selectedRegion;
  final TextEditingController _customUrl = TextEditingController();
  @override
  void initState() {
    super.initState();
    _loadPreferences();
  }

  Future<void> _loadPreferences() async {
    final prefs = await SharedPreferences.getInstance();
    setState(() {
      _apiKey.text = prefs.getString('apiKey') ?? "";
      print(_apiKey);
      String? selectedRegionString = prefs.getString('selectedRegion');
      if (selectedRegionString != null) {
        _selectedRegion = AmityRegion.values.firstWhere(
          (e) => e.toString() == selectedRegionString,
          orElse: () => AmityRegion.sg,
        );
      }
      if (_selectedRegion == AmityRegion.custom) {
        _customUrl.text = prefs.getString('customUrl') ?? "";
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('API Configuration'),
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            TextFormField(
              controller: _apiKey,
              decoration: InputDecoration(
                labelText: 'API Key',
                border: OutlineInputBorder(),
              ),
            ),
            SizedBox(height: 20),
            Text('Select Region:'),
            ...AmityRegion.values.map((region) {
              return RadioListTile<AmityRegion>(
                title: Text(region.toString().split('.').last.toUpperCase()),
                value: region,
                groupValue: _selectedRegion,
                onChanged: (AmityRegion? value) {
                  setState(() {
                    _selectedRegion = value;
                    if (value != AmityRegion.custom) {
                      _customUrl.text = ""; // Reset custom URL
                    }
                  });
                },
              );
            }).toList(),
            if (_selectedRegion == AmityRegion.custom) ...[
              SizedBox(height: 20),
              TextFormField(
                decoration: InputDecoration(
                  labelText: 'Custom URL',
                  border: OutlineInputBorder(),
                ),
                controller: _customUrl,
              ),
            ],
            SizedBox(height: 40),
            ElevatedButton(
                child: Text('Initialize'),
                onPressed: () async {
                  if (_apiKey != null &&
                      _selectedRegion != null &&
                      (_selectedRegion != AmityRegion.custom ||
                          _customUrl != null)) {
                    final prefs = await SharedPreferences.getInstance();
                    print(_apiKey);
                    await prefs.setString('apiKey', _apiKey.text);
                    await prefs.setString(
                        'selectedRegion', _selectedRegion.toString());
                    if (_selectedRegion == AmityRegion.custom &&
                        _customUrl != null) {
                      await prefs.setString('customUrl', _customUrl.text);
                    }
                    print("save pref");

                    await AmitySLEUIKit().initUIKit(
                        apikey: _apiKey.text,
                        region: _selectedRegion!,
                        customEndpoint: _customUrl.text);
                    // Navigate to the nextx page
                    Navigator.push(
                      context,
                      MaterialPageRoute(builder: (context) => AmityApp()),
                    );
                  }
                }),
          ],
        ),
      ),
    );
  }
}

class AmityApp extends StatelessWidget {
  const AmityApp({super.key});
  @override
  Widget build(BuildContext context) {
    return AmitySLEProvider(
      child: Builder(builder: (context2) {
        return UserListPage();
      }),
    );
  }
}

class UserListPage extends StatefulWidget {
  @override
  _UserListPageState createState() => _UserListPageState();
}

class _UserListPageState extends State<UserListPage> {
  List<String> _usernames = [];
  TextEditingController _controller = TextEditingController();

  @override
  void initState() {
    super.initState();
    _loadUsernames();
  }

  _loadUsernames() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    setState(() {
      _usernames = prefs.getStringList('usernames') ?? [];
    });
  }

  _addUsername() async {
    if (_controller.text.isNotEmpty) {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      _usernames.add(_controller.text);
      prefs.setStringList('usernames', _usernames);
      _controller.clear();
      setState(() {});
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('User List'),
      ),
      body: Column(
        children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: TextField(
              controller: _controller,
              decoration: InputDecoration(
                labelText: 'Username',
                border: OutlineInputBorder(),
              ),
            ),
          ),
          ElevatedButton(
            onPressed: _addUsername,
            child: Text('Add Username'),
          ),
          Expanded(
            child: ListView.builder(
              itemCount: _usernames.length,
              itemBuilder: (context, index) {
                return ListTile(
                  title: Text(_usernames[index]),
                  onTap: () async {
                    print("login");

                    ///Step 3: login with Amity
                    await AmitySLEUIKit().registerDevice(
                      context: context,
                      userId: _usernames[index],
                      callback: (isSuccess, error) {
                        print("callback:${isSuccess}");
                        if (isSuccess) {
                          print("success");
                          Navigator.of(context).push(
                            MaterialPageRoute(
                              builder: (context) =>
                                  SecondPage(username: _usernames[index]),
                            ),
                          );
                        } else {
                          print(error);
                          AmityDialog().showAlertErrorDialog(
                              title: "Error", message: error.toString());
                        }
                      },
                    );
                  },
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}

class SecondPage extends StatelessWidget {
  const SecondPage({super.key, required this.username});
  final String username;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Welcome, $username'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) => ThirdPage(username: username),
                  ),
                );
              },
              child: Text('Social'),
            ),
            ElevatedButton(
              onPressed: () {
                // Navigator.of(context).pushNamed('/third',
                //     arguments: {'username': username, 'feature': 'Chat'});
              },
              child: Text('Chat'),
            ),
          ],
        ),
      ),
    );
  }
}

class ThirdPage extends StatelessWidget {
  const ThirdPage({super.key, required this.username});
  final String username;

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Social'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ListTile(
              title: Text('Register push notification'),
              onTap: () {
                // Navigate or perform action based on 'Global Feed' tap
                AmitySLEUIKit().registerNotification("asdasdasdasd",
                    (isSuccess, error) {
                  return;
                });
              },
            ),
            ListTile(
              title: Text('unregister'),
              onTap: () {
                // Navigate or perform action based on 'Global Feed' tap
                AmitySLEUIKit().unRegisterDevice();
              },
            ),
            ListTile(
              title: Text('Global Feed'),
              onTap: () {
                // Navigate or perform action based on 'Global Feed' tap
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) =>
                      const Scaffold(body: GlobalFeedScreen()),
                ));
              },
            ),
            ListTile(
              title: Text('User Profile'),
              onTap: () {
                // Navigate or perform action based on 'User Profile' tap
              },
            ),
            ListTile(
              title: Text('Newsfeed'),
              onTap: () {
                // Navigate or perform action based on 'Newsfeed' tap
              },
            ),
            ListTile(
              title: Text('Create Community'),
              onTap: () {
                // Navigate or perform action based on 'Newsfeed' tap
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => Scaffold(body: CreateCommunityPage()),
                ));
              },
            ),
            ListTile(
              title: Text('Create Post'),
              onTap: () {
                // Navigate or perform action based on 'Newsfeed' tap
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => Scaffold(body: PostToPage()),
                ));
              },
            ),
            ListTile(
              title: Text('My Community'),
              onTap: () {
                // Navigate or perform action based on 'Newsfeed' tap
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => Scaffold(body: MyCommunityPage()),
                ));
              },
            ),
            ListTile(
              title: Text('Explore'),
              onTap: () {
                // Navigate or perform action based on 'Newsfeed' tap
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => Scaffold(body: CommunityPage()),
                ));
              },
            ),
          ],
        ),
      ),
    );
  }
}
Social Plus Console.
API key in Security page