Closed rajeshsonu closed 12 months ago
Even I have the same problem.
I also faced the same issue. A simple workaround will be to send all the data in the deeplink of notification. You can send the data through firebase dynamic links or create a deep link yourself and extract it with uni_links. The latter is better as it will launch app directly instead of launching browser first.
Same problem
@darshanclevertap any news ?
@rajeshsonu @maxim-ivanchuk-idf
The issue has been resolved in CleverTap Flutter SDK version 1.8.0. Please upgrade your SDK version to v1.8.0 or later.
Also, we have thoroughly documented the entire implementation of handling notification clicks for various states (foreground, background, and killed state) across Android and iOS platforms. Please review the documentation for the same.
Hi team Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 18116933e7 (3 months ago) • 2021-10-15 10:46:35 -0700 Engine • revision d3ea636dc5 Tools • Dart 2.14.4 clevertap_plugin: ^1.4.0
Flowed all steps as per documentation
When app in foreground able to read notification payload data. when it comes to terminated state unable to read notification payload data.
Sample Code :
import 'dart:async'; import 'dart:convert'; import 'dart:io' show Platform;
import 'package:clevertap_plugin/clevertap_plugin.dart'; import 'package:flutter/material.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:fluttertoast/fluttertoast.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); }
class _MyAppState extends State {
late CleverTapPlugin _clevertapPlugin;
var inboxInitialized = false;
var optOut = false;
var offLine = false;
var enableDeviceNetworkingInfo = false;
@override void initState() { super.initState(); initPlatformState(); activateCleverTapFlutterPluginHandlers(); CleverTapPlugin.setDebugLevel(3); CleverTapPlugin.createNotificationChannel( "xxxxx", "xxxxx", "xxxxx", 3, true); CleverTapPlugin.initializeInbox(); CleverTapPlugin.registerForPush(); //only for iOS //var initialUrl = CleverTapPlugin.getInitialUrl(); var profile = { 'Name': 'XXX' + 'XXXXX', 'Identity': 'XXX', 'Email': 'XXXXXXX@gmail.com', 'Phone': '91-XXXXXXXXX', 'App_Version_Code': '1.x.0', 'App_Version_Sub_Code': 'x' }; CleverTapPlugin.profileSet(profile); }
// Platform messages are asynchronous, so we initialize in an async method. Future initPlatformState() async {
if (!mounted) return;
}
void activateCleverTapFlutterPluginHandlers() { _clevertapPlugin = new CleverTapPlugin(); _clevertapPlugin .setCleverTapPushAmpPayloadReceivedHandler(pushAmpPayloadReceived); _clevertapPlugin.setCleverTapPushClickedPayloadReceivedHandler( pushClickedPayloadReceived); _clevertapPlugin.setCleverTapInAppNotificationDismissedHandler( inAppNotificationDismissed); _clevertapPlugin .setCleverTapProfileDidInitializeHandler(profileDidInitialize); _clevertapPlugin.setCleverTapProfileSyncHandler(profileDidUpdate); _clevertapPlugin.setCleverTapInboxDidInitializeHandler(inboxDidInitialize); _clevertapPlugin .setCleverTapInboxMessagesDidUpdateHandler(inboxMessagesDidUpdate); _clevertapPlugin .setCleverTapDisplayUnitsLoadedHandler(onDisplayUnitsLoaded); _clevertapPlugin.setCleverTapInAppNotificationButtonClickedHandler( inAppNotificationButtonClicked); _clevertapPlugin.setCleverTapInboxNotificationButtonClickedHandler( inboxNotificationButtonClicked); _clevertapPlugin.setCleverTapFeatureFlagUpdatedHandler(featureFlagsUpdated); _clevertapPlugin .setCleverTapProductConfigInitializedHandler(productConfigInitialized); _clevertapPlugin .setCleverTapProductConfigFetchedHandler(productConfigFetched); _clevertapPlugin .setCleverTapProductConfigActivatedHandler(productConfigActivated); }
void inAppNotificationDismissed(Map<String, dynamic> map) { this.setState(() { print("inAppNotificationDismissed called"); }); }
void inAppNotificationButtonClicked(Map<String, dynamic>? map) { this.setState(() { print("inAppNotificationButtonClicked called = ${map.toString()}"); }); }
void inboxNotificationButtonClicked(Map<String, dynamic>? map) { this.setState(() { print("inboxNotificationButtonClicked called = ${map.toString()}"); }); }
void profileDidInitialize() { this.setState(() { print("profileDidInitialize called"); }); }
void profileDidUpdate(Map<String, dynamic>? map) { this.setState(() { print("profileDidUpdate called"); }); }
void inboxDidInitialize() { this.setState(() { print("inboxDidInitialize called"); inboxInitialized = true; }); }
void inboxMessagesDidUpdate() { this.setState(() async { print("inboxMessagesDidUpdate called"); int? unread = await CleverTapPlugin.getInboxMessageUnreadCount(); int? total = await CleverTapPlugin.getInboxMessageCount(); print("Unread count = " + unread.toString()); print("Total count = " + total.toString()); }); }
void onDisplayUnitsLoaded(List? displayUnits) {
this.setState(() async {
List? displayUnits = await CleverTapPlugin.getAllDisplayUnits();
print("Display Units = " + displayUnits.toString());
});
}
void featureFlagsUpdated() { print("Feature Flags Updated"); this.setState(() async { bool? booleanVar = await CleverTapPlugin.getFeatureFlag("BoolKey", false); print("Feature flag = " + booleanVar.toString()); }); }
void productConfigInitialized() { print("Product Config Initialized"); this.setState(() async { await CleverTapPlugin.fetch(); }); }
void productConfigFetched() { print("Product Config Fetched"); this.setState(() async { await CleverTapPlugin.activate(); }); }
void productConfigActivated() { print("Product Config Activated"); this.setState(() async { String? stringvar = await CleverTapPlugin.getProductConfigString("StringKey"); print("PC String = " + stringvar.toString()); int? intvar = await CleverTapPlugin.getProductConfigLong("IntKey"); print("PC int = " + intvar.toString()); double? doublevar = await CleverTapPlugin.getProductConfigDouble("DoubleKey"); print("PC double = " + doublevar.toString()); }); }
void pushAmpPayloadReceived(Map<String, dynamic> map) { print("pushAmpPayloadReceived called"); this.setState(() async { var data = jsonEncode(map); print("Push Amp Payload = " + data.toString()); CleverTapPlugin.createNotification(data); Fluttertoast.showToast( msg: "pushAmpPayloadReceived", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 5, backgroundColor: Colors.red, textColor: Colors.white, fontSize: 16.0); }); }
void pushClickedPayloadReceived(Map<String, dynamic> map) { print("pushClickedPayloadReceived called"); this.setState(() async { var data = jsonEncode(map); print("on Push Click Payload = " + data.toString()); Fluttertoast.showToast( msg: "pushClickedPayloadReceived", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 5, backgroundColor: Colors.red, textColor: Colors.white, fontSize: 16.0); }); }