Last updated:
0 purchases
nudge core
Overview #
The Nudge Flutter Package allows you to integrate the core analytics and experience triggering nudge package provided by Nudge into your Flutter application. With this package, you can engage your users with interactive games and promotions.
Getting Started #
To get started with the Nudge Flutter Package, follow these steps:
Navigate to Nudge's official website to explore the in-app experiences you can enable in your app.
Register your product on our website Nudge.
From the Nudge website, you will obtain a unique secret key. Use this secret key while initializing the package.
Usage #
After adding the NudgeCore package to your project's dependencies in the pubspec.yaml file, you need to run flutter pub get command to fetch the package and make it accessible in your Flutter project. This command will download the package and its dependencies, allowing you to import and utilize the Nudge package in your code.
To initialize the NudgeCore class with a reusable variable name and access all its functions through it, follow these steps:
Import the NudgeCore package into your Dart file:
import 'package:nudge_core/nudge_core.dart';
copied to clipboard
Create an instance of the NudgeCore class with your desired variable name and add:
token (required): The secret key obtained from the Nudge website, used for authentication.
final core = NudgeCore(<TOKEN>);
copied to clipboard
Nudge Provider #
The NudgeProvider is a Flutter widget that should be wrapped around the main MaterialApp widget in your application. It enables integration with the Nudge package and requires two parameters: nudgeInstance and child.
Parameters #
app (required): An instance of the Nudge core initialized with your unique token. The Nudge core manages your application's integration with the Nudge platform.
child (required): The child widget, typically the MaterialApp widget, that will be rendered below the NudgeProvider. It should include the navigatorKey parameter.
Example
return NudgeProvider(
nudgeInstance: core,
child: MaterialApp(
navigatorKey: NudgeProviderState.navigatorKey,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Home(),
),
);
copied to clipboard
Initializing session #
Whenever a distinct user Id which is used to identify users at the client's end is defined, call the initSession function to initialize the user session.
await core.initSession(externalId:'CLIENT_IDENTIFIABLE_USER_ID');
copied to clipboard
You can also send more user attributes along with the user ID for making segments of audiences.
await core.initSession('CLIENT_IDENTIFIABLE_USER_ID',
properties: <String, dynamic>{
"name": "Client User 1",
"age": 27,
"gender": "M",
"country":"US",
});
copied to clipboard
Start Tracking Events #
Make shure you have initialized sesstion before tracking
To track an event, simply call
await core.track(type:'EVENT_TYPE');
copied to clipboard
You can also add event properties for analytics and .making segments of users based on the properties of their events performed for custom audience experiences.
await core.track(type:'EVENT_TYPE',
properties: <String, dynamic>{
"product": "Fortune Cookies",
"quantity": 5,
"countryOfExport":"US",
});
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.