With Social Plus UIKit 2.3, we have introduced a new way to Authentication process. Just follow the guide below.
Adding required permissions
Your app may require the following permissions to work properly;
Camera access
Microphone access
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:
NSCameraUsageDescription
NSMicrophoneUsageDescription
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 Social Plus Console.
After logging in Console:
Click Settings to expand the menu.
Select Security.
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.
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.
classMyAppextendsStatelessWidget {@overrideWidgetbuild(BuildContext context) {returnAmitySLEProvider( 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:constText("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.
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.
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.