Track Push & In-App Notifications for Flutter
- 1 Minute to read
- Print
- DarkLight
Track Push & In-App Notifications for Flutter
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
Once you've installed the Mapp Engage SDK flutter plugin and updated the AppConfig.plist, you can implement push and in-app notification tracking. You can find another example in our sample flutter app.
Implement the Mapp Engage SDK delegate methods to track the receiving/opening of push notifications:
import 'package:mapp_sdk/mapp_sdk.dart';
//initialize mapp sdk
await MappSdk.engage(Config.sdkKey, Config.googleProjectId, Config.server,
Config.appID, Config.tenantID);
// add listeners for delegate methods
MappSdk.handledRemoteNotification =
(dynamic arguments) => remoteNotificationHandler(arguments);
MappSdk.handledRichContent =
(dynamic arguments) => richContentHandler(arguments);
//Android only methods
MappSdk.handledPushOpen =
(dynamic arguments) => pushOpenedHandler(arguments);
MappSdk.handledPushDismiss =
(dynamic arguments) => pushDismissedHandler(arguments);
MappSdk.handledPushSilent =
(dynamic arguments) => pushSilentHandler(arguments);
//define methods from listeners
void remoteNotificationHandler(dynamic arguments) {
print("remote Notification received!");
print(arguments);
}
void richContentHandler(dynamic arguments) {
print("rich Content received!");
print(arguments);
}
void pushOpenedHandler(dynamic arguments) {
print("Push opened!");
print(arguments);
}
void pushDismissedHandler(dynamic arguments) {
print("Push dismissed!");
print(arguments);
}
void pushSilentHandler(dynamic arguments) {
print("Push silent!");
print(arguments);
}
Next, For in-app notification tracking, you need to include tracking as follows:
// add listeners for delegate methods
MappSdk.didReceiveDeepLinkWithIdentifier = (dynamic arguments) =>
didReceiveDeepLinkWithIdentifierHandler(arguments);
MappSdk.didReceiveInappMessageWithIdentifier = (dynamic arguments) =>
didReceiveInappMessageWithIdentifierHandler(arguments);
MappSdk.didReceiveCustomLinkWithIdentifier = (dynamic arguments) =>
didReceiveCustomLinkWithIdentifierHandler(arguments);
MappSdk.didReceiveInBoxMessages =
(dynamic arguments) => didReceiveInBoxMessagesHandler(arguments);
MappSdk.inAppCallFailedWithResponse =
(dynamic arguments) => inAppCallFailedWithResponseHandler(arguments);
MappSdk.didReceiveInBoxMessage =
(dynamic arguments) => didReceiveInBoxMessageHandler(arguments);
//define methods for listeners
void didReceiveInappMessageWithIdentifierHandler(dynamic arguments) {
print("Inapp message received!");
print(arguments);
}
void didReceiveCustomLinkWithIdentifierHandler(dynamic arguments) {
print("Custom Link With Identifier received!");
print(arguments);
}
void didReceiveInBoxMessagesHandler(dynamic arguments) {
print("Inbox Messages received!");
print(arguments);
_showMyDialog("Inbox messages", "", jsonEncode(arguments));
}
void inAppCallFailedWithResponseHandler(dynamic arguments) {
print("inApp Call Failed received!");
print(arguments);
}
void didReceiveInBoxMessageHandler(dynamic arguments) {
print("Inbox Message received!");
print(arguments);
}
Was this article helpful?