### Start ChromeDriver Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/README.md Start the ChromeDriver executable on the specified port. Ensure the Chrome version matches the installed browser. ```bash chromedriver --port=4444 ``` -------------------------------- ### Custom Application Class for Intercom Initialization (Android) Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Create a custom Application class in Android to initialize the Intercom SDK during the application's lifecycle. This ensures Intercom is ready before your app's main components start. ```kotlin import android.app.Application class MyApp: Application() { override fun onCreate() { super.onCreate() } } ``` ```kotlin import android.app.Application import io.maido.intercom.IntercomFlutterPlugin class MyApp : Application() { override fun onCreate() { super.onCreate() // Add this line with your keys IntercomFlutterPlugin.initSdk(this, appId = "appId", androidApiKey = "androidApiKey") } } ``` -------------------------------- ### Get FCM/APNS Token and Send to Intercom Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Use this snippet to obtain the appropriate push notification token (FCM for Android, APNS for iOS) via Firebase Messaging and send it to Intercom for targeted push notifications. ```dart final firebaseMessaging = FirebaseMessaging.instance; final intercomToken = Platform.isIOS ? await firebaseMessaging.getAPNSToken() : await firebaseMessaging.getToken(); Intercom.instance.sendTokenToIntercom(intercomToken); ``` -------------------------------- ### Run Single Integration Test (Linux) Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/README.md Execute a specific integration test file using a shell script on Linux. This is useful for running individual test cases. ```bash ./run_test.sh integration_test/TEST_NAME.dart ``` -------------------------------- ### Run All Integration Tests (Linux) Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/README.md Execute all integration tests using a shell script on Linux. This command runs all tests defined in the test suite. ```bash ./run_test.sh ``` -------------------------------- ### Run Flutter Web Integration Tests Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/README.md Execute Flutter integration tests targeting the web server with Chrome browser. This command specifies the driver and target test files. ```bash flutter drive -d web-server --browser-name=chrome --driver=test_driver/integration_test.dart --target=integration_test/intercom_flutter_web_test.dart ``` -------------------------------- ### Pre-define Intercom Settings for Web Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/README.md Use this script to pre-define Intercom settings like hiding the default launcher when using the web implementation. ```html ``` -------------------------------- ### Initialize Intercom SDK with Dart Define Variables Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Read Intercom API keys defined via `--dart-define` and initialize the Intercom SDK in your Dart code. Provides default empty strings if variables are not set. ```dart String appId = String.fromEnvironment("INTERCOM_APP_ID", ""); String androidKey = String.fromEnvironment("INTERCOM_ANDROID_KEY", ""); String iOSKey = String.fromEnvironment("INTERCOM_IOS_KEY", ""); Intercom.instance.initialize(appId, iosApiKey: iOSKey, androidApiKey: androidKey); ``` -------------------------------- ### Initialize and Display Intercom Messenger in Flutter Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Initialize the Intercom SDK with your app ID and API keys, then display the messenger. Ensure Flutter binding is initialized and keys are correctly set. ```dart import 'package:flutter/material.dart'; import 'package:intercom_flutter/intercom_flutter.dart'; void main() async { // initialize the flutter binding. WidgetsFlutterBinding.ensureInitialized(); // initialize the Intercom. // make sure to add keys from your Intercom workspace. // don't forget to set up the custom application class on Android side. await Intercom.instance.initialize('appIdHere', iosApiKey: 'iosKeyHere', androidApiKey: 'androidKeyHere'); runApp(App()); } class App extends StatelessWidget { @override Widget build(BuildContext context) { return FlatButton( child: Text('Open Intercom'), onPressed: () async { // messenger will load the messages only if the user is registered in Intercom. // either identified or unidentified. await Intercom.instance.displayMessenger(); }, ); } } ``` -------------------------------- ### Configure Intercom Settings and Service Worker Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/example/web/index.html Set Intercom initialization options and register the service worker for web integration. Use 'hide_default_launcher: true' to disable the default launcher. ```javascript window.intercomSettings = { hide_default_launcher: true, // set this to false, if you want to show the default launcher }; if ('serviceWorker' in navigator) { window.addEventListener('flutter-first-frame', function () { navigator.serviceWorker.register('flutter_service_worker.js'); }); } ``` -------------------------------- ### Configure Intercom Settings Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/web/index.html Set custom configuration options for the Intercom widget, such as hiding the default launcher. This should be done before the Intercom script is loaded. ```javascript window.intercomSettings = { hide_default_launcher: true, // set this to false, if you want to show the default launcher }; ``` -------------------------------- ### Initialize Intercom SDK in Android Native Code Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Initialize the Intercom SDK within your Android `Application` class using the `BuildConfig` fields populated with Intercom API keys. Ensure `IntercomFlutterPlugin.initSdk` is called. ```kotlin import android.app.Application import android.os.Build import io.maido.intercom.IntercomFlutterPlugin class MyApp : Application() { override fun onCreate() { super.onCreate() // Add this line with your keys IntercomFlutterPlugin.initSdk(this, appId = BuildConfig.INTERCOM_APP_ID, androidApiKey = BuildConfig.INTERCOM_ANDROID_KEY) } } ``` -------------------------------- ### Enable AndroidX and Jetifier Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Ensure AndroidX and Jetifier support are enabled in your android/gradle.properties file for compatibility. ```properties android.useAndroidX=true android.enableJetifier=true ``` -------------------------------- ### Configure Application Tag in AndroidManifest.xml Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Specify your custom application class name in the application tag of your AndroidManifest.xml file to ensure it's used by the Android system. ```xml ``` -------------------------------- ### Initialize Intercom Widget Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter_web/example/web/index.html This script initializes the Intercom widget. It checks if the Intercom function is available, updates it with settings, or loads the script if it's not present. It ensures the script is loaded asynchronously on page load. ```javascript (function(){ var w=window; var ic=w.Intercom; if(typeof ic==="function"){ ic('reattach_activator'); ic('update',w.intercomSettings); }else{ var d=document; var i=function(){i.c(arguments);}; i.q=[]; i.c=function(args){i.q.push(args);}; w.Intercom=i; var l=function(){ var s=d.createElement('script'); s.type='text/javascript'; s.async=true; s.src='https://widget.intercom.io/widget/'; var x=d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if(document.readyState==='complete'){ l(); }else if(w.attachEvent){ w.attachEvent('onload',l); }else{ w.addEventListener('load',l,false); } } })(); ``` -------------------------------- ### Pass Intercom Keys with Flutter CLI Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Avoid hardcoding Intercom API keys by passing them as environment variables using the `--dart-define` flag with `flutter run` or `flutter build` commands. ```bash flutter run --dart-define="INTERCOM_APP_ID=appID" --dart-define="INTERCOM_ANDROID_KEY=androidKey" --dart-define="INTERCOM_IOS_KEY=iosKey" ``` -------------------------------- ### Set BuildConfig Fields for Intercom Keys in Android Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Add Intercom API keys read from dart environment variables to your Android app's `buildConfigField` in `build.gradle` for native access. ```gradle defaultConfig { ... buildConfigField 'String', 'INTERCOM_APP_ID', "${dartEnvironmentVariables.INTERCOM_APP_ID}" buildConfigField 'String', 'INTERCOM_ANDROID_KEY', "${dartEnvironmentVariables.INTERCOM_ANDROID_KEY}" } ``` -------------------------------- ### Read Dart Environment Variables in Android Gradle Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Configure your Android `build.gradle` file to read `dart-defines` passed from the Flutter build command. This allows native Android code to access these variables. ```gradle def dartEnvironmentVariables = [] if (project.hasProperty('dart-defines')) { dartEnvironmentVariables = project.property('dart-defines') .split(',') .collectEntries { def pair = new String(it.decodeBase64(), 'UTF-8').split('=') [(pair.first()): pair.last()] } } ``` -------------------------------- ### Android Permissions for Intercom Source: https://github.com/deepak786/intercom_flutter/blob/master/intercom_flutter/README.md Declare necessary internet permissions and optional permissions like read external storage and vibrate in your AndroidManifest.xml. ```xml ``` ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.