inngage_plugin 4.1.0
inngage_plugin: ^4.1.0 copied to clipboard
Inngage Plugin for Flutter applications for marketing campaign optimization using Push Notification and In App Messages channels.
inngage_plugin #
This SDK inf lutter aims to enable integration with the Inngage platform
Add the plugin to your project #
- Open the pubspec.yaml
- add to the dependencies section
Access here to see the official documentation on the inngage website
inngage_plugin:3.2.0
How to use #
final json = {
"nome": "User 01",
"dt_nascimento": "01/09/1970",
"genero": "M",
"cartao": "N",
"ultimo_abastecimento": "10/09/2018",
"total_abastecido": "290,00"
};
final inngageWebViewProperties = InngageWebViewProperties(
appBarColor: Colors.pink,
appBarText: Text(
'AppTitle',
),
backgroundColor: Colors.white,
loaderColor: Colors.pink,
debuggingEnabled: true,
withJavascript: true,
withLocalStorage: true,
withZoom: true,
);
await InngageSDK.subscribe(
appToken: 'appToken',
friendlyIdentifier: 'user@gmail.com',
customFields: json,
phoneNumber: 'phoneNumber',
email: 'user@gmail.com',
blockDeepLink:true,
firebaseListenCallback: (data) => print(data['additional_data']),
navigatorKey: navigatorKey,
inngageWebViewProperties: inngageWebViewProperties,
requestAdvertiserId: false,
requestGeoLocator: false,
);
Future.delayed(const Duration(seconds: 5)).then((value){
InngageNotificationMessage.subscribe();
});
InngageEvent.setDebugMode(true);
InngageEvent.setUserPhone("phoneNumber");
await InngageEvent.sendEvent(
eventName: 'MyOtherEventWithoutEventValues',
appToken: 'appToken',
identifier: 'user@gmail.com',
eventValues: {
'location': '12312312312',
},
);
await InngageEvent.sendEvent(
eventName: 'send_test',
appToken: 'appToken',
identifier: 'user@gmail.com',
);
var localNotification = InngageNotificationMessage.flutterLocalNotificationsPlugin;
Call subscribe() on a InngageSDK to request it.
Custom fields #
The custom fields passed to InngageSDK.subscribe (or set later with
InngageEvent.setCustomFields) are sent on the next subscriber registration.
To write them to the Inngage API right away, with no session side effects (no
device update, no event), use addCustomField:
final ok = await InngageSDK.addCustomField(
identifier: 'user@gmail.com', // required: e-mail, CPF, customer id…
customField: {'plano': 'premium', 'pontos': 1250},
email: 'user@gmail.com', // optional
phoneNumber: '5511999998888', // optional, digits only with country code
identity: {'vtex': '7a3c9f1e'}, // optional external ids
);
Field names must exist in the app's custom-field catalog on the Inngage
platform; unknown names are ignored by the API. On success the fields are
merged into InngageProperties.customFields, and identifier (plus email
and phoneNumber, when given) become the SDK's current values, so the next
subscriber registration carries the same data. identifier is required on
purpose: the anonymous subscriber registered before login is keyed by a
device uuid, and fields must never silently land there.
addCustomField replaces InngageUtils.addUserData, which is now deprecated:
addUserData only updated the local state (identifier, contact, custom
fields) and relied on the next registration to send it, while
addCustomField persists the same data on the API immediately. addUserData
keeps working unchanged in 4.x and will be removed in 5.0.
After a successful registration the SDK also keeps the subscriber id returned
by the API in InngageProperties.subscriberId.
In-App Messages #
Since 4.0.0 In-App messages no longer arrive through push payloads. The SDK
fetches them on demand from the Inngage API (/v4/message/objectMessage) when
your app asks for one — for example after the splash screen, on the login
screen, or on any specific route:
await InngageInApp.show(
context: context, // optional: defaults to the navigatorKey passed to subscribe
handledBySdk: true, // SDK executes deep links / browser / in-app browser
onMetadata: (metadata) {
// "metadata" actions deliver key-value pairs to the app, with no navigation
},
);
If there is no In-App message to display, nothing is rendered and the call returns silently.
Important: the In-App flow depends on the
app_idand the device registration token persisted from the subscription. Make sureInngageSDK.subscribe+ the subscriber registration have completed at least once before callingInngageInApp.show.
To handle every action yourself instead of letting the SDK navigate, pass
handledBySdk: false and an onAction callback receiving the InAppV2Action.
Countdown #
Campaigns with type: "Countdown" render a ticking deadline card
(days/hours/minutes/seconds boxes) toward countdown.endDate, with action
buttons that behave like banner buttons. Already-expired campaigns are not
rendered; if the deadline is reached while the card is open, it switches to
the expired title/body.
Scratch (raspadinha) #
Campaigns with type: "Scratch" render a scratch card: the weighted draw
happens before the cover is shown, so the revealed prize is already the
result. Scratching past revealPercent completes the reveal and shows the
win/lose panel with a copy-to-clipboard coupon. The drawn prize is delivered
to the app via onScratchResult — nothing is sent to the API.
Wheel (roleta) #
Campaigns with type: "Wheel" render a fortune wheel: an optional
lead-capture form (before or after the spin), a weighted draw that happens
before the animation, and a win/lose result panel with a copy-to-clipboard
coupon. The SDK delivers the captured lead and the drawn slice to the app —
nothing is sent to the API:
await InngageInApp.show(
context: context,
onLeadCaptured: (lead) => print('lead: $lead'), // {label: value}
onWheelResult: (slice) => print('${slice.label} win=${slice.isWin}'),
);