aware 0.1.9

aware #

Flutter plugin for AIQAware


Prerequisite #

AIQAware studio #

  • Create project in AIQAware studio

  • Create android, ios app in project

  • Get App ID, API key, App package(bundle) name

  • For iOS, you have to put Apple team ID, APNs key ID, APNs auth key to studio. Those can be found Apple developer program

Apple team IDMembership - Team ID
APNs key IDCertificates, Identifiers & Profiles - Keys - APNs Key's Key ID
APNs auth keyAPNs key ID's value (body of .p8 file)

Android #

  1. Create aware-client-config.json in src/main/assets and put information

     {
       "version": 1,
       "project_id": "AAAAAAAAAA",
       "app_id": "AAAAAAAAAA",
       "api_key": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
     }
    
  2. Add permissions to AndroidManifest.xml

     <!-- Required Permissions to Use the SDK -->
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <!-- targetSDKVersion is Android API Level 28 or higher -->
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    

More information, see simple app

iOS #

  1. Create AwareClient-Info.plist in Runner and put information (Be sure to create in xcode)

     <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     <plist version="1.0">
     <dict>
       <key>API_KEY</key>
       <string>AAAAAAAAAAAAAAAAAAAAAAAAAAA</string>
       <key>APP_ID</key>
       <string>AAAAAAAAAA</string>
       <key>PROJECT_ID</key>
       <string>AAAAAAAAAA</string>
     </dict>
     </plist>
    
  2. Add Capabilities

    • background modes

      • Location updates
      • Background fetch
      • Remote notifications
    • wifi information

    • push notification

  3. Add permission strings to plist

       Privacy - Location When In Use Usage Description
       Privacy - Location Always Usage Description
       Privacy - Location Always and When In Use Usage Description
       Privacy - Media Library Usage Description
       Privacy - Photo Library Usage Description
       Privacy - Microphone Usage Description
       Privacy - Calendars Usage Description
       Privacy - Motion Usage Description
    

Prerequisite for development #

  1. Go to example directory

  2. Build Android, iOS projects

For Android

flutter build apk

For iOS

flutter build ios --no-codesign

Develop plugins on Android #

  • Open example/android project in Android Studio.

  • You can see aware, android projects.

  • android is example project

  • aware is plugin project

Develop plugins on iOS #

  • Open example/ios/Runner.xcworkspace in xcode

  • You can see Runner, Pods

  • Runner is example project

  • Pods/DevelopmentPods/../../example/ios/.symlink/plugins/aware/ios/Classes is plugin project

example/lib/main.dart

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

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

class ExampleApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyApp(),
    );
  }
}

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

class _MyAppState extends State<MyApp> {
  String registeredToken = '';
  String unregisterSucceed = '';
  String isRegistered = '';
  String isServiceEnabled = '';
  bool serviceEnable = false;
  String profile = '';
  String clientSecret = '';

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

  Widget _buildTestZone({String title = '', Widget button}) {
    return Column(
      children: <Widget>[
        Text(title),
        button,
      ],
    );
  }

  Widget _buildTextButton({String title, VoidCallback onPressed}) {
    return MaterialButton(
      color: Colors.blue,
      child: Text(
        title,
        style: const TextStyle(color: Colors.white),
      ),
      onPressed: onPressed,
    );
  }

  void _reset() {
    setState(() {
      registeredToken = '';
      unregisterSucceed = '';
      isRegistered = '';
      isServiceEnabled = '';
      serviceEnable = false;
      profile = '';
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
        actions: <Widget>[
          FlatButton(
            child: const Text(
              'Reset',
              style: TextStyle(color: Colors.white),
            ),
            onPressed: () {
              _reset();
            },
          ),
        ],
      ),
      body: ListView(
        children: <Widget>[
          _buildTestZone(
            title: registeredToken,
            button: _buildTextButton(
              title: 'Register',
              onPressed: () async {
                final token = await Aware.register();

                setState(() {
                  registeredToken = token;
                });
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'Unregister succeed?: $unregisterSucceed',
            button: _buildTextButton(
              title: 'Unregister',
              onPressed: () async {
                try {
                  final unregistered = await Aware.unregister();
                  setState(() {
                    unregisterSucceed = unregistered.toString();
                  });
                } catch (e) {
                  setState(() {
                    unregisterSucceed = e.toString();
                  });
                }
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'isRegistered?: $isRegistered',
            button: _buildTextButton(
              title: 'isRegistered',
              onPressed: () async {
                try {
                  final isRegistered = await Aware.isRegistered();
                  setState(() {
                    this.isRegistered = isRegistered.toString();
                  });
                } catch (e) {
                  setState(() {
                    isRegistered = e.toString();
                  });
                }
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            button: _buildTextButton(
              title: 'Collect',
              onPressed: () async {
                await Aware.collect([CollectorType.location, CollectorType.wifi, CollectorType.bluetooth]);
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'isServiceEnabled?: $isServiceEnabled',
            button: _buildTextButton(
              title: 'isServiceEnabled',
              onPressed: () async {
                try {
                  final isServiceEnabled = await Aware.isServiceEnabled();
                  setState(() {
                    this.isServiceEnabled = isServiceEnabled.toString();
                  });
                } catch (e) {
                  setState(() {
                    isServiceEnabled = e.toString();
                  });
                }
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'setServiceEnabled',
            button: Switch(
              value: serviceEnable,
              onChanged: (bool value) async {
                await Aware.setServiceEnabled(value);
                setState(() {
                  serviceEnable = value;
                });
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'profile?: $profile',
            button: _buildTextButton(
              title: 'Get profile',
              onPressed: () async {
                try {
                  final profile = await Aware.getProfile();
                  setState(() {
                    this.profile = profile;
                  });
                } catch (e) {
                  setState(() {
                    profile = e.toString();
                  });
                }
              },
            ),
          ),
          const Divider(color: Colors.black),
          _buildTestZone(
            title: 'clientSecret?: $clientSecret',
            button: _buildTextButton(
              title: 'Get clientSecret',
              onPressed: () async {
                try {
                  final clientSecret = await Aware.getClientSecret();
                  setState(() {
                    this.clientSecret = clientSecret;
                  });
                } catch (e) {
                  setState(() {
                    clientSecret = e.toString();
                  });
                }
              },
            ),
          ),
          const Divider(color: Colors.black),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  aware: ^0.1.9

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

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

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

Format lib/aware.dart.

Run flutter format to format lib/aware.dart.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-16 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test