intercom_plugin 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new66

intercom_plugin #

A plugin that translates the Intercom SDK into a plugin for Flutter

Usage #

Import package:intercom_plugin/intercom_plugin.dart and use the methods in Intercom class.

Example #

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

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

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    Intercom.initialize(
      androidApiKey: 'android_sdk-516e7d257ee2d4b98bf801c146e6c5c92c5a77e5', 
      iOSApiKey: 'ios_sdk-f89bc4dce1f127d8a65b36e18dcbbc5baf53b907', 
      appId: 'xypa8ezx'
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              FlatButton(
                child: Text("Display messenget"),
                onPressed: () async{
                  await Intercom.displayMessenger();
                },
              ),
              FlatButton(
                child: Text("Logs a event"),
                onPressed: () async{
                  await Intercom.logEvent("First event", metadata: {
                    "meta":"data"
                  });
                  
                  Scaffold.of(context).showSnackBar(
                    SnackBar(
                      content: Text("Event logged with success"),
                    )
                  );
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}

Android integration #

First you need to add this permission

<uses-permission android:name="android.permission.INTERNET"/>

Other permissions that you can set, but is optional

<manifest>
    ...
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    ...
</manifest>

Push notifications support #

This plugin allows push notifications for Intercom and FCM. You can explore better in the IntercomInterceptor.kt file, but basically, we verify if the push is coming from Intercom and pass to him the responsability to handle the push, otherwise FCM will handle it.

  • First, implement the firebase_messaging and take a look in the android part.
  • Then, add the Firebase server key to Intercom, as described here (you can skip 1 and 2)
  • Lastly, add this to you AndroidManifest.xml, above the closing tag
  <service
    android:name="dev.lucaseduardo.intercom_plugin.IntercomInterceptor"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
      <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
  </service>

0.1.1 #

Inserting result call on logout method

0.1.0 #

Initial version of the library

example/lib/main.dart

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

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

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    Intercom.initialize(
      androidApiKey: 'android_sdk-516e7d257ee2d4b98bf801c146e6c5c92c5a77e5',
      iOSApiKey: 'ios_sdk-f89bc4dce1f127d8a65b36e18dcbbc5baf53b907',
      appId: 'xypa8ezx'
    );

    Intercom.registerUnidentifiedUser();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Builder(
          builder: (context) => Center(
            child: Column(
              children: <Widget>[
                FlatButton(
                  child: Text("Display messenger"),
                  onPressed: () async{
                    await Intercom.displayMessenger();
                  },
                ),
                FlatButton(
                  child: Text("Logs a event"),
                  onPressed: () async{
                    await Intercom.logEvent("First event", metadata: {
                      "meta":"data"
                    });

                    Scaffold.of(context).showSnackBar(
                        SnackBar(
                          content: Text("Event logged with success"),
                        )
                    );
                  },
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  intercom_plugin: ^0.1.1

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:intercom_plugin/intercom_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
39
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
66
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.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:intercom_plugin/intercom_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:intercom_plugin/intercom_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:intercom_plugin/intercom_plugin.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:intercom_plugin/intercom_plugin.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • intercom_plugin that is a package requiring null.

Health suggestions

Format lib/intercom_plugin.dart.

Run flutter format to format lib/intercom_plugin.dart.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Running dartdoc failed with the following output: NoSuchMethodError: The getter 'attributes' was called on null. Receiver: null Tried calling: attributes

#0      DartdocCustomizer._addPubPackageLink (package:pub_dev/dartdoc/customization.dart:168:17)
#1      DartdocCustomizer.customizeHtml (package:pub_dev/dartdoc/customization.dart:61:7)
#2      DartdocCustomizer.customizeFile (package:pub_dev/dartdoc/customization.dart:35:31)
<asynchronous suspension>
#3      DartdocCustomizer.customizeDir (package:pub_dev/dartdoc/customization.dart:26:25)
<asynchronous suspension>
#4      DartdocJobProcessor.process (package:pub_dev/dartdoc/dartdoc_runner.dart:211:14)
<asynchronous suspension>
#5      JobProcessor.run (package:pub_dev/job/job.dart:69:28)
<asynchronous suspension>
#6      JobMaintenance.run (package:pub_dev/job/job.dart:119:18)
#7      _workerMain.<anonymous closure> (package:pub_dev/service/entrypoint/dartdoc.dart:111:26)
#8      StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#9      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#10     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#11     _rootRunUnary (dart:async/zone.dart:1192:38)
#12     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#13     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#15     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#16     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#17     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#18     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#19     DartdocJobProcessor.generateDocsForSdk (package:pub_dev/dartdoc/dartdoc_runner.dart)
#20     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#21     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#22     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#23     _rootRunUnary (dart:async/zone.dart:1192:38)
#24     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#25     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#26     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#27     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#28     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#29     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
#30     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#31     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#32     _rootRun (dart:async/zone.dart:1184:13)
#33     _CustomZone.run (dart:async/zone.dart:1077:19)
#34     _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#35     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#36     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#37     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#38     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#39     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

Homepage URL isn't helpful. (-10 points)

Update the homepage field from pubspec.yaml: link to a website about the package or use the source repository URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
intl ^0.16.1 0.16.1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
path 1.7.0
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