Last updated:
0 purchases
intercom carrousel
intercom_flutter #
Flutter wrapper for Intercom Android and iOS projects.
Usage #
Import package:intercom_flutter/intercom_flutter.dart and use the methods in Intercom class.
Example:
import 'package:intercom_flutter/intercom_flutter.dart';
void main() async {
await Intercom.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 {
await Intercom.displayMessenger();
},
);
}
}
copied to clipboard
See Intercom Android and iOS package documentation for more information.
Android #
Permissions:
<uses-permission android:name="android.permission.INTERNET"/>
copied to clipboard
Optional permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
copied to clipboard
Enable AndroidX + Jetifier support in your android/gradle.properties file (see example app):
android.useAndroidX=true
android.enableJetifier=true
copied to clipboard
Push notifications in combination with FCM
This plugin works in combination with the firebase_messaging plugin to receive Push Notifications. To set this up:
First, implement firebase_messaging and check if it works: https://pub.dev/packages/firebase_messaging#android-integration
Then, add the Firebase server key to Intercom, as described here: https://developers.intercom.com/installing-intercom/docs/android-fcm-push-notifications#section-step-3-add-your-server-key-to-intercom-for-android-settings (you can skip 1 and 2)
Add the following to your AndroidManifest.xml file, so incoming messages are handled by Intercom:
<service
android:name="io.maido.intercom.PushInterceptService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
copied to clipboard
just above the closing </application> tag.
Ask FireBaseMessaging for the FCM token that we need to send to Intercom, and give it to Intercom (so Intercam can send push messages to the correct device):
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
token = await _firebaseMessaging.getToken();
Intercom.sendTokenToIntercom(token);
copied to clipboard
Now, if either FireBase direct (e.g. by your own backend server) or Intercom sends you a message, it will be delivered your Android phone.
Firebase Background Messages
If you are handling background messages in firebase_messaging you need to do some extra work for everything to work together:
Remove the above mentioned <service android:name="io.maido.intercom.PushInterceptService" ... from your AndroidManifest.xml.
In your background messages handler, pass the relevant messages to Intercom:
import 'package:intercom_flutter/intercom_flutter.dart' show Intercom;
Future<dynamic> backgroundMessageHandler(Map<String, dynamic> message) async {
final data = (message['data'] as Map).cast<String, dynamic>();
if (await Intercom.isIntercomPush(data)) {
await Intercom.handlePush(data);
return;
}
// Here you can handle your own background messages
}
copied to clipboard
iOS #
Make sure that you have a NSPhotoLibraryUsageDescription entry in your Info.plist.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.