diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ccbb27c..4e99ba92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## CHANGE LOG +### Version 1.2.3 (July 20, 2021) +* Supports [CleverTap Android SDK v4.2.0](https://github.com/CleverTap/clevertap-android-sdk/releases/tag/core-v4.2.0) +* Adds fix for NPE [#58](https://github.com/CleverTap/clevertap-flutter/issues/58) +* Adds fix for `recordScreen` NPE [#54](https://github.com/CleverTap/clevertap-flutter/issues/54) + ### Version 1.2.2 (May 21, 2021) * Supports [CleverTap Android SDK v4.1.1](https://github.com/CleverTap/clevertap-android-sdk/releases/tag/core-v4.1.1) * Supports [CleverTap iOS SDK v3.9.4](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/3.9.4) diff --git a/README.md b/README.md index 94eb9556..66901230 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ To get started, sign up [here](https://clevertap.com/live-product-demo/) ```yaml dependencies: -clevertap_plugin: 1.2.2 +clevertap_plugin: 1.2.3 ``` - Run `flutter packages get` to install the SDK diff --git a/android/build.gradle b/android/build.gradle index a5499095..4e586390 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ group 'com.clevertap.clevertap_plugin' -version '1.2.2' +version '1.2.3' buildscript { repositories { @@ -42,7 +42,7 @@ android { dependencies { testImplementation 'junit:junit:4.13' - implementation 'com.clevertap.android:clevertap-android-sdk:4.1.1' + implementation 'com.clevertap.android:clevertap-android-sdk:4.2.0' implementation 'androidx.fragment:fragment:1.1.0' implementation 'androidx.core:core:1.3.0' } diff --git a/android/src/main/java/com/clevertap/clevertap_plugin/CleverTapPlugin.java b/android/src/main/java/com/clevertap/clevertap_plugin/CleverTapPlugin.java index 2424b466..ecbbbb9d 100644 --- a/android/src/main/java/com/clevertap/clevertap_plugin/CleverTapPlugin.java +++ b/android/src/main/java/com/clevertap/clevertap_plugin/CleverTapPlugin.java @@ -906,6 +906,10 @@ private void invokeMethodOnUiThread(final String methodName, final String clever private void invokeMethodOnUiThread(final String methodName, final Map map) { final MethodChannel channel = this.channel; + if (channel == null) { + Log.d(TAG, "methodChannel is null"); + return; + } runOnMainThread(() -> channel.invokeMethod(methodName, map)); } @@ -1291,7 +1295,7 @@ private void setPersonalization(Result result, boolean enable) { private void setPushToken(MethodCall call, Result result, PushType type) { String token = call.argument("token"); if (isCleverTapNotNull(cleverTapAPI)) { - switch (type.toString()) { + switch (type.getType()) { case "fcm": cleverTapAPI.pushFcmRegistrationId(token, true); break; diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index d2d11ef5..f0e12a76 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -56,7 +56,7 @@ flutter { dependencies { testImplementation 'junit:junit:4.13' //implementation fileTree('libs') - implementation 'com.clevertap.android:clevertap-android-sdk:4.1.1' + implementation 'com.clevertap.android:clevertap-android-sdk:4.2.0' implementation 'com.google.firebase:firebase-messaging:20.2.4' implementation 'androidx.core:core:1.3.0' implementation 'androidx.fragment:fragment:1.1.0' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 079c29f6..578e4366 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - CleverTap-iOS-SDK (3.9.4): - SDWebImage (~> 5.1) - - clevertap_plugin (1.2.2): + - clevertap_plugin (1.2.3): - CleverTap-iOS-SDK (= 3.9.4) - Flutter - Flutter (1.0.0) @@ -26,7 +26,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CleverTap-iOS-SDK: 923e0a8829f4f8a16a8412f1e661d9b650d9633d - clevertap_plugin: 17da2e4fc60747aac275b91440722e0e23145781 + clevertap_plugin: 00a8c28a82aedd75a16d93143f4c6738dad326e4 Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 9b2da67f..fac820f1 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - B4B797B60C63ACC2A30C4C7C /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A2E551018913B7400FA1650B /* libPods-Runner.a */; }; + DE9F316D4885F9BE0CBD66EA /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B3C46A97E9CAD4128D2A0A73 /* libPods-Runner.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -32,18 +32,18 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 10C0A1E4C71AC64BC7959BDB /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 2ED6E38453F1A5D41B0CDD01 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 38988E2E3FCCDF34543B25EC /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 18A31F618917247F54AFBE78 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 49A81C5223D5E278006388A5 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 49A81C5323D6EB1D006388A5 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; }; 49A81C5523D6FD0F006388A5 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; - 6C2F1937C1F5E61716C2BC4C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 93847282920A03629649A560 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -52,7 +52,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - A2E551018913B7400FA1650B /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B3C46A97E9CAD4128D2A0A73 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -61,7 +61,7 @@ buildActionMask = 2147483647; files = ( 49A81C5623D6FD0F006388A5 /* UserNotifications.framework in Frameworks */, - B4B797B60C63ACC2A30C4C7C /* libPods-Runner.a in Frameworks */, + DE9F316D4885F9BE0CBD66EA /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -71,9 +71,9 @@ 57EF2E58EE59B48415544B69 /* Pods */ = { isa = PBXGroup; children = ( - 2ED6E38453F1A5D41B0CDD01 /* Pods-Runner.debug.xcconfig */, - 38988E2E3FCCDF34543B25EC /* Pods-Runner.release.xcconfig */, - 6C2F1937C1F5E61716C2BC4C /* Pods-Runner.profile.xcconfig */, + 10C0A1E4C71AC64BC7959BDB /* Pods-Runner.debug.xcconfig */, + 18A31F618917247F54AFBE78 /* Pods-Runner.release.xcconfig */, + 93847282920A03629649A560 /* Pods-Runner.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -83,7 +83,7 @@ children = ( 49A81C5523D6FD0F006388A5 /* UserNotifications.framework */, 49A81C5323D6EB1D006388A5 /* AdSupport.framework */, - A2E551018913B7400FA1650B /* libPods-Runner.a */, + B3C46A97E9CAD4128D2A0A73 /* libPods-Runner.a */, ); name = Frameworks; sourceTree = ""; @@ -150,14 +150,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 755700BCA92B646DA9F7F9C3 /* [CP] Check Pods Manifest.lock */, + 4453C74191FCC9E7F35240A8 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 93B891758EF7C5C5D25CB988 /* [CP] Copy Pods Resources */, + 47F4E531F18A76CBF0726BFB /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -229,7 +229,7 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 755700BCA92B646DA9F7F9C3 /* [CP] Check Pods Manifest.lock */ = { + 4453C74191FCC9E7F35240A8 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -251,7 +251,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 93B891758EF7C5C5D25CB988 /* [CP] Copy Pods Resources */ = { + 47F4E531F18A76CBF0726BFB /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( diff --git a/example/lib/main.dart b/example/lib/main.dart index c34aa928..25b17e5c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -758,15 +758,48 @@ class _MyAppState extends State { } void recordEvent() { + var now = new DateTime.now(); var eventData = { // Key: Value 'first': 'partridge', - 'second': 'turtledoves' + 'second': 'turtledoves', + 'date': CleverTapPlugin.getCleverTapDate(now), + 'number': 1 }; CleverTapPlugin.recordEvent("Flutter Event", eventData); showToast("Raised event - Flutter Event"); } + void recordNotificationClickedEvent() { + var eventData = { + /// Key: Value + 'nm': 'Notification message', + 'nt': 'Notification title', + 'wzrk_id': '0_0', + 'wzrk_cid': 'Notification Channel ID' + + ///other CleverTap Push Payload Key Values found in Step 3 of + ///https://developer.clevertap.com/docs/android#section-custom-android-push-notifications-handling + }; + CleverTapPlugin.pushNotificationClickedEvent(eventData); + showToast("Raised event - Notification Clicked"); + } + + void recordNotificationViewedEvent() { + var eventData = { + /// Key: Value + 'nm': 'Notification message', + 'nt': 'Notification title', + 'wzrk_id': '0_0', + 'wzrk_cid': 'Notification Channel ID' + + ///other CleverTap Push Payload Key Values found in Step 3 of + ///https://developer.clevertap.com/docs/android#section-custom-android-push-notifications-handling + }; + CleverTapPlugin.pushNotificationViewedEvent(eventData); + showToast("Raised event - Notification Viewed"); + } + void recordChargedEvent() { var item1 = { // Key: Value diff --git a/example/pubspec.lock b/example/pubspec.lock index dd7289de..35c722bc 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -35,7 +35,7 @@ packages: path: ".." relative: true source: path - version: "1.2.2" + version: "1.2.3" clock: dependency: transitive description: diff --git a/ios/clevertap_plugin.podspec b/ios/clevertap_plugin.podspec index aa26b7a3..85d64134 100644 --- a/ios/clevertap_plugin.podspec +++ b/ios/clevertap_plugin.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'clevertap_plugin' - s.version = '1.2.2' + s.version = '1.2.3' s.summary = 'CleverTap Flutter plugin.' s.description = 'The CleverTap iOS SDK for App Analytics and Engagement.' s.homepage = 'https://github.com/CleverTap/clevertap-ios-sdk' diff --git a/lib/clevertap_plugin.dart b/lib/clevertap_plugin.dart index 03121ee8..d5d110eb 100644 --- a/lib/clevertap_plugin.dart +++ b/lib/clevertap_plugin.dart @@ -348,15 +348,15 @@ class CleverTapPlugin { ///Record Notification Clicked event static Future pushNotificationClickedEvent( Map extras) async { - return await _channel - .invokeMethod('pushNotificationClickedEvent', {'notificationData': extras}); + return await _channel.invokeMethod( + 'pushNotificationClickedEvent', {'notificationData': extras}); } ///Record Notification Viewed event static Future pushNotificationViewedEvent( Map extras) async { - return await _channel - .invokeMethod('pushNotificationViewedEvent', {'notificationData': extras}); + return await _channel.invokeMethod( + 'pushNotificationViewedEvent', {'notificationData': extras}); } /// Record a Screen View event @@ -409,16 +409,14 @@ class CleverTapPlugin { // and last time timestamp of the event. static Future> eventGetDetail(String eventName) async { Map response = - await (_channel.invokeMethod('eventGetDetail', {'eventName': eventName}) - as FutureOr>); + await _channel.invokeMethod('eventGetDetail', {'eventName': eventName}); return response.cast(); } /// Returns a Map of event names and corresponding event details of all the events raised static Future> getEventHistory(String eventName) async { - Map response = await (_channel - .invokeMethod('getEventHistory', {'eventName': eventName}) - as FutureOr>); + Map response = await _channel + .invokeMethod('getEventHistory', {'eventName': eventName}); return response.cast(); } @@ -566,8 +564,7 @@ class CleverTapPlugin { /// Returns a Map of UTMDetail object which consists of UTM parameters like source, medium & campaign static Future> sessionGetUTMDetails() async { Map response = - await (_channel.invokeMethod('sessionGetUTMDetails', {}) - as FutureOr>); + await _channel.invokeMethod('sessionGetUTMDetails', {}); return response.cast(); } @@ -606,9 +603,8 @@ class CleverTapPlugin { /// Returns a json string representation of CTInboxMessage for given messageId static Future> getInboxMessageForId( String messageId) async { - Map response = await (_channel - .invokeMethod('getInboxMessageForId', {'messageId': messageId}) - as FutureOr>); + Map response = await _channel + .invokeMethod('getInboxMessageForId', {'messageId': messageId}); return response.cast(); } @@ -652,8 +648,7 @@ class CleverTapPlugin { ///Returns Display unit info as a Map static Future> getDisplayUnitForId(String unitId) async { Map response = - await (_channel.invokeMethod('getDisplayUnitForId', {'unitId': unitId}) - as FutureOr>); + await _channel.invokeMethod('getDisplayUnitForId', {'unitId': unitId}); return response.cast(); } diff --git a/pubspec.yaml b/pubspec.yaml index 84ef930b..f990d7ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: clevertap_plugin description: The CleverTap Flutter SDK for Mobile Customer Engagement,Analytics and Retention solutions. -version: 1.2.2 +version: 1.2.3 homepage: https://github.com/CleverTap/clevertap-flutter environment: