Gist
Search…
Flutter
Our Flutter library wraps around the native iOS & Android libraries

Installation

1
dependencies:
2
flutter:
3
sdk: flutter
4
5
gist_flutter: ^1.1.1
Copied!

Android

Open the Project build.gradle file and update your kotlin version
1
ext.kotlin_version = '1.5.30'
Copied!
Open the App build.gradle file and update the minimum SDK version
1
minSdkVersion 19
Copied!
Note: If a version is higher then the one specified here, you can leave it as is.

iOS

Open the project's .xcworkspace file, select the project and make sure the deployment target is 10 or higher.

Setup

1
import 'package:gist_flutter/gist.dart';
Copied!
Gist can be initialized anywhere within your app, the organizationId property can be retrieved from the Gist dashboard.
1
Gist.setup("your-organization-id");
Copied!

User Token

If your app is relying on Gist’s webhook service to trigger in-app messages, a user token must be set. This user token should be generated by your services and set at any point during runtime, for example, login or registration.
1
Gist.setUserToken("unique-user-token");
Copied!
To clear the user token:
1
Gist.clearUserToken();
Copied!

Current Route

Gist is able to show messages when a user reaches a particular route within your product. This is completely optional but messages containing route rules will not be displayed unless the route matches.
In your route handler add:
1
Gist.setCurrentRoute("users/home");
Copied!

Broadcasts

Broadcasts enable you to receive messages based on topics the client is subscribed to.

Subscribing

1
Gist.subscribeToTopic("announcements");
Copied!

Unsubscribing

1
Gist.unsubscribeFromTopic("announcements");
Copied!

Clear All Topics

1
Gist.clearTopics();
Copied!

Event Handling

Implement the GistDelegate into your class and add your class as an event listener.
1
Gist.eventListeners.add(this);
Copied!
1
@override
2
onAction(message, action) {
3
debugPrint("Action: Message instance: ${message.instanceId}, with id: ${message.messageId} and queue id: ${message.queueId}");
4
debugPrint("Action: Message action: ${action.action} on route ${action.currentRoute}");
5
}
6
7
@override
8
onError(message) {
9
debugPrint("Error: Message instance: ${message.instanceId}, with id: ${message.messageId} and queue id: ${message.queueId}");
10
}
11
12
@override
13
onMessageDismissed(message) {
14
debugPrint("Dismissed: Message instance: ${message.instanceId}, with id: ${message.messageId} and queue id: ${message.queueId}");
15
}
16
17
@override
18
onMessageShown(message) {
19
debugPrint("Shown: Message instance: ${message.instanceId}, with id: ${message.messageId} and queue id: ${message.queueId}");
20
}
Copied!

Messages

To programmatically dismiss messages Gist.dismissMessage() can be used to dismiss any active modal message being displayed.

Important

The current Flutter implementation doesn't support message embedding or manual triggering of Gist messages, these features will be available at a later date.