applozic_flutter 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Applozic flutter chat plugin #

A flutter wraper for Applozic native android and iOS SDKs.

Getting Started #

Sign up for Applozic to get your application Id. This application Id is used to login user to applozic.

Prerequisites #

Apps using Applozic can target Xcode 11 or later and AndroidX is required.

Installation #

  1. Add the below dependency in your pubspec.yaml file:
 dependencies:
  # other dependencies
 applozic_flutter: ^0.0.2
  1. Install the package as below:
  flutter pub get
  1. For iOS, navigate to your App/iOS directory from terminal and run the below command:
pod install

Note: Applozic iOS requires min iOS platform version 10 and uses dynamic frameworks. Make sure you have the below settings at the top of your iOS/Podfile:

platform :ios, '10.0'
use_frameworks!
  1. Import the applozic_flutter in your .dart file to use the methods from Applozic:
import 'package:applozic_flutter/applozic_flutter.dart';

Authentication #

Login #

Create Applozic user and pass user to login() function as below:

dynamic user = {
      'applicationId': "<APPLICATION_ID>",   //Mandatory
      'userId': userId.text,                 //Mandatory
      'displayName': displayName.text,
      'password': password.text,
      'authenticationTypeId': 1              //Mandatory
  };

ApplozicFlutter.login(user).then((response) {
      print("Login success : " + response)
    }).catchError((error, stack) =>
      print("Error while logging in : " + error.toString()));

Note: Please remember you have to log in once and only after you log out you must log in again. Use below code to check if the user is already logged in:

ApplozicFlutter.isLoggedIn().then((isLoggedIn) {
        if (isLoggedIn) {
          //The user is logged in
         } esle {
          //The user is not logged in
         }
     });

Update logged in user details #

You can update the logged in user details as below:

  dynamic user = {
                    'displayName': '<New name>'
                    'imageLink': '<New Image URL>'
                  }

  ApplozicFlutter.updateUserDetail(user)
                        .then(
                            (value) => print("User details updated : " + value))
                        .catchError((e, s) => print(
                            "Unable to update user details : " + e.toString()));

Get logged in userId #

You can get the userId of the logged in user as below:

  ApplozicFlutter.getLoggedInUserId().then((userId) {
      print("Logged in userId : " + userId);
    }).catchError((error, stack) {
      print("User get error : " + error);
   });

Conversation #

Launch main chat screen #

Launch the main chat screen as below:

  ApplozicFlutter.launchChat();

Launch Chat with a specific User #

Launch the conversation with a user by passing the userId as below:

  ApplozicFlutter.launchChatWithUser("<USER_ID>");

Launch Chat with a specific Group #

Launch the conversation with a group by passing the groupId as below:

  ApplozicFlutter.launchChatWithGroupId(<GROUP_ID>)
                        .then((value) =>
                            print("Launched successfully : " + value))
                        .catchError((error, stack) {
                      print("Unable to launch group : " + error.toString());
                    });

Create a group #

To create a group, you need to create a groupInfo object and then pass it to the create group function as below:

  dynamic groupInfo = {
          'groupName': "My group",
          'groupMemberList': ['userId1', 'userId2'],
          'imageUrl': 'https://www.applozic.com/favicon.ico',
          'type': 2,
          'admin': 'userId1',
          'metadata': {
            'plugin': "Flutter",
            'platform': "Android"
          }
        };

  ApplozicFlutter.createGroup(groupInfo)
            .then((groupId) {
              print("Group created sucessfully: " + groupId);
              ApplozicFlutter.launchChatWithGroupId(groupId)
                  .then((value) => print("Launched successfully : " + value))
                  .catchError((error, stack) {
                print("Unable to launch group : " + error.toString());
              });
            })
            .catchError((error, stack) =>
                print("Group created failed : " + error.toString()));

Add contacts #

Add contacts to applozic as below:

  dynamic user1 = {
      'userId': "user1",
      'displayName': ""User 1,
      "metadata": {
        'plugin': "Flutter",
        'platform': "Android"
      }
    };

  dynamic user2 = {
      'userId': "user2",
      'displayName': ""User 2,
      "metadata": {
        'plugin': "Flutter",
        'platform': "Android"
      }
    };

  ApplozicFlutter.addContacts([user1, user2])
        .then((value) => print("Contact added successfully: " + value))
        .catchError((e, s) => print("Failed to add contacts: " + e.toString()));

Logout #

Logout from applozic as below:

 ApplozicFlutter.logout()
                .then((value) =>
                  print("Logout successfull")
                .catchError((error, stack) =>
                  print("Logout failed : " + error.toString()));

Sample app #

You can checkout Applozic Flutter sample app that demonstrates the use of this plugin.

In case of any queries regarding this plugin, write to us at support@applozic.com.

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'home.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:applozic_flutter/applozic_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TextStyle style = TextStyle(fontFamily: 'Montserrat', fontSize: 20.0);

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

  @override
  void dispose() {
    // Clean up the controller when the widget is disposed.
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Applozic sample app'),
        ),
        body: LoginPage(),
      ),
    );
  }
}

class LoginPage extends StatelessWidget {
  TextEditingController userId = new TextEditingController();
  TextEditingController displayName = new TextEditingController();
  TextEditingController password = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    try {
      ApplozicFlutter.isLoggedIn().then((value) {
        print("Logged in : " + value.toString());
        if (value) {
          print("Logged in after check");
          Navigator.push(
              context, MaterialPageRoute(builder: (context) => HomePage()));
        }
      });
    } on Exception catch (e) {
      print("isLogged in error : " + e.toString());
    }

    return SingleChildScrollView(
      child: Container(
        padding: const EdgeInsets.all(36.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SizedBox(
              height: 155.0,
              child: Image.asset(
                "assets/ic_launcher.png",
                fit: BoxFit.contain,
              ),
            ),
            new TextField(
              controller: userId,
              decoration: new InputDecoration(
                  contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                  hintText: "UserId *",
                  border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(32.0))),
            ),
            SizedBox(height: 10),
            new TextField(
              controller: displayName,
              decoration: new InputDecoration(
                  contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                  hintText: "Display name",
                  border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(32.0))),
            ),
            SizedBox(height: 10),
            new TextField(
              controller: password,
              obscureText: true,
              decoration: new InputDecoration(
                  contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                  hintText: "Password *",
                  border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(32.0))),
            ),
            SizedBox(height: 10),
            new Material(
                elevation: 5.0,
                borderRadius: BorderRadius.circular(30.0),
                color: Color(0xff01A0C7),
                child: new MaterialButton(
                  onPressed: () {
                    loginUser(context);
                  },
                  minWidth: 400,
                  padding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                  child: Text("Login",
                      textAlign: TextAlign.center,
                      style: TextStyle(fontFamily: 'Montserrat', fontSize: 20.0)
                          .copyWith(
                              color: Colors.white,
                              fontWeight: FontWeight.bold)),
                ))
          ],
        ),
      ),
    );
  }

  void loginUser(context) {
    dynamic user = {
      'applicationId': "applozic-sample-app",
      'userId': userId.text,
      'displayName': displayName.text,
      'password': password.text
    };

    ApplozicFlutter.login(user).then((value) {
      if (value != null) {
        Navigator.push(
            context, MaterialPageRoute(builder: (context) => HomePage()));
      }
    }).catchError((error, stack) =>
        print("Error while logging in : " + error.toString()));
    /*try {
      dynamic user = {
        'applicationId': "applozic-sample-app",
        'userId': userId.text,
        'displayName': displayName.text,
        'password': password.text
      };

      ApplozicFlutter.login(user).then((value) {
        if (value != null) {
          Navigator.push(
              context, MaterialPageRoute(builder: (context) => HomePage()));
        }
      });
    } on Exception catch (e) {
      print("Error while logging in : " + e.toString());
    }*/
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  applozic_flutter: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:applozic_flutter/applozic_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
48
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:applozic_flutter/applozic_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:applozic_flutter/applozic_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:applozic_flutter/applozic_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:applozic_flutter/applozic_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • applozic_flutter that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

13 out of 13 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test