wannatalkcore 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

wannatalkcore #

Wannatalk Official Flutter plugin.

Getting Started #

Edit the pubspec.yaml file in your app directory to define the Wannatalk SDK dependency:

dependencies:
  wannatalkcore: ^0.0.2

iOS Setup #

  1. Request WTService-Info.plist from wannatalk.ai and drag it into your application. When prompted, select "Copy items if needed" and continue.

  2. Add below keys in your application's Info.plist

    <key>NSPhotoLibraryUsageDescription</key>
    <string>To save in-chat photos and videos</string>
    <key>NSContactsUsageDescription</key>
    <string>To locate friends already on the Wannatalk network</string>
    <key>NSCameraUsageDescription</key>
    <string>To take photos and videos to send to friends in-chat</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>To display it in map</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>To record live photos and movies</string>
    
  3. Add this line to your application pod file

    pod 'WTExternalSDK', :git =>'https://github.com/edzehoo/WannatalkAPI-iOS.git', :tag => '1.5.1'

  4. That's it! Run the app

To strip simulator architecture framework for your app submission #

  1. Copy trim.sh file into your project folder.
  2. Create Run Script Phase in Build Phases of your application target.
  3. Paste "$SRCROOT/trim.sh" inside the body of Run Script Phase.
  4. Enable Run script only when installing and Show environment variables in build log.

Android Setup #

  1. Request wannatalk-services.json from wannatalk.ai and drag it into your application assets directory

  2. Enable multiDexEnabled in your application build.gradle

    android {
        defaultConfig {
            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }
    
  3. Set colorPrimary, colorPrimaryDark and colorAccent attributes in app's color.xml (src/main/res/values/colors.xml)

  4. That's it! Run the app

Usage #

import 'package:wannatalkcore/wannatalkcore.dart';
Wannatalkcore.login(onCompletion: (WTResult result) {
  if (result.success) {
  
  }
});
Wannatalkcore.silentLogin("<user_identifier>", { displayname: "name", key1: "Value1", key2: "Value2"}, onCompletion: (WTResult result) {
  if (result.success) {
  }
});

To check login status #

bool loggedIn = await Wannatalkcore.isUserLoggedIn;
Wannatalkcore.logout(onCompletion: (WTResult result) {
});

Wannatalk events #

Wannatalkcore.setMethodCallHandler(onReceivedEvent:(WTEventResponse eventResponse) {

});

HelpDesk #

To load your organization profile #

Wannatalkcore.loadOrganizationProfile(autoOpenChat, onCompletion: (WTResult result){
});

Collaboration #

To view all chats #

Wannatalkcore.loadChats(onCompletion: (WTResult result) {
});

To view all users #

Wannatalkcore.loadUsers(onCompletion: (WTResult result) {
});

Other #

To show or hide guide button #

WannatalkConfig.showGuideButton(true); // default = true

To enable or disable sending audio message #

WannatalkConfig.allowSendAudioMessage(false);  // default = true

To show or hide add participants option in new ticket page and chat item profile page #

WannatalkConfig.allowAddParticipants(false);    // default = true

To show or hide remove participants option in chat item profile #

WannatalkConfig.allowRemoveParticipants(false); // default = false

To show or hide welcome message #

WannatalkConfig.showWelcomeMessage(false);            // default = false

To show or hide Profile Info page #

WannatalkConfig.showProfileInfoPage(false);           // default = true

To create auto tickets: #

Chat ticket will create automatically when auto tickets is enabled, otherwise default ticket creation page will popup

WannatalkConfig.enableAutoTickets(true);           // default = false

To show or hide close chat button in chat page #

WannatalkConfig.showExitButton(true);               // default = false

To show or hide participants in chat profile page #

WannatalkConfig.showChatParticipants(false);          // default = true

To enable or disbale chat profile page #

WannatalkConfig.enableChatProfile(false);           // default = true

To allow modify in chat profile page #

WannatalkConfig.allowModifyChatProfile(false);       // default = true

To set Inactive chat timeout: #

Chat session will end if user is inactive for timeout interval duration. If timeout interval is 0, chat session will not end automatically. The default timout interval is 1800 seconds (30 minutes).

double timeoutInterval = 1800; // Default Value: 1800 seconds ~ 30 minutes
WannatalkConfig.setInactiveChatTimeoutInterval(timeoutInterval);

0.0.1 #

  • initial release.

0.0.2 #

  • Fixes

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool _userLoggedIn = false;

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

    Wannatalkcore.setMethodCallHandler(onReceivedEvent:(WTEventResponse eventResponse) {

    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool loggedIn = await Wannatalkcore.isUserLoggedIn;

    if (!mounted) return;

    WannatalkConfig.showGuideButton(false);
    WannatalkConfig.showProfileInfoPage(false);
    WannatalkConfig.allowSendAudioMessage(false);
    WannatalkConfig.allowAddParticipants(false);
    WannatalkConfig.enableAutoTickets(true);

    WannatalkConfig.showExitButton(true);
    WannatalkConfig.enableChatProfile(false);

    setState(() {
      _userLoggedIn = loggedIn;
    });
  }

  void login(){
    Wannatalkcore.login(onCompletion: (WTResult result) {
      if (result.success) {
        setState(() {
          _userLoggedIn = true;
        });
      }

    });
  }

  void silentLogin() {
    String userIdentifier = "<user_identifier>";
    Map userInfo = { "displayname": "Guest", "key1": "Value1", "key2": "Value2"};

    Wannatalkcore.silentLogin(userIdentifier, userInfo, onCompletion: (WTResult result) {
      if (result.success) {
        setState(() {
          _userLoggedIn = true;
        });
      }
    });
  }


  void logout() {
    Wannatalkcore.logout(onCompletion: (WTResult result) {
      if (result.success) {
        setState(() {
          _userLoggedIn = false;
        });
      }
    });
  }


  void presentOrgProfile(bool autoOpenChat) {
    Wannatalkcore.loadOrganizationProfile(autoOpenChat, onCompletion: (WTResult result){
      if (result.success) {

      }
    });
  }

  void presentChats() {
    Wannatalkcore.loadChats(onCompletion: (WTResult result) {
      if (result.success) {

      }
    });
  }

  void presentUsers() {
    Wannatalkcore.loadUsers(onCompletion: (WTResult result) {
      if (result.success) {

      }
    });
  }

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Wannatalk Demo app'),
        ),
        body: new Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              if (!_userLoggedIn) new RaisedButton(
                onPressed: () {
                  login();
                },
                child: new Text('Login'),
              ),
              if (!_userLoggedIn) new RaisedButton(
                onPressed: () {
                  silentLogin();
                },
                child: new Text('Silent Login'),
              ),
              if (_userLoggedIn) new RaisedButton(
                onPressed: () {logout();},
                child: new Text('Logout'),
              ),
              if (_userLoggedIn) new RaisedButton(
                onPressed: () {presentOrgProfile(true);},
                child: new Text('Org Profile'),
              ),
              if (_userLoggedIn) new RaisedButton(
                onPressed: () {presentChats();},
                child: new Text('Chats'),
              ),
              if (_userLoggedIn) new RaisedButton(
                onPressed: () {presentUsers();},
                child: new Text('Users'),
              )
            ],
          ),
        )
      ),
    );
  }

}

Use this package as a library

1. Depend on it

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


dependencies:
  wannatalkcore: ^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:wannatalkcore/wannatalkcore.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:wannatalkcore/wannatalkcore.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:wannatalkcore/wannatalkcore.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:wannatalkcore/wannatalkcore.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:wannatalkcore/wannatalkcore.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [wannatalkcore] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

44 out of 44 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.

Fix lib/wannatalkcore.dart. (-0.50 points)

Analysis of lib/wannatalkcore.dart reported 1 hint:

line 90 col 21: The value of the field '_kWTIsUserLoggedIn' isn't used.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

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.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
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