-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiaoweii
committed
Oct 26, 2023
1 parent
86bdd9c
commit 53a2187
Showing
14 changed files
with
324 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 56 additions & 23 deletions
79
...oid/src/main/kotlin/software/aws/solution/clickstream_flutter/ClickstreamFlutterPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,68 @@ | ||
package software.aws.solution.clickstream_flutter | ||
|
||
import androidx.annotation.NonNull | ||
|
||
import android.app.Activity | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import io.flutter.plugin.common.MethodCall | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
import io.flutter.plugin.common.MethodChannel.Result | ||
import software.aws.solution.clickstream.ClickstreamAnalytics | ||
|
||
|
||
/** ClickstreamFlutterPlugin */ | ||
class ClickstreamFlutterPlugin: FlutterPlugin, MethodCallHandler { | ||
/// The MethodChannel that will the communication between Flutter and native Android | ||
/// | ||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it | ||
/// when the Flutter Engine is detached from the Activity | ||
private lateinit var channel : MethodChannel | ||
|
||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "clickstream_flutter") | ||
channel.setMethodCallHandler(this) | ||
} | ||
|
||
override fun onMethodCall(call: MethodCall, result: Result) { | ||
if (call.method == "getPlatformVersion") { | ||
result.success("Android ${android.os.Build.VERSION.RELEASE}") | ||
} else { | ||
result.notImplemented() | ||
class ClickstreamFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { | ||
/// The MethodChannel that will the communication between Flutter and native Android | ||
/// | ||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it | ||
/// when the Flutter Engine is detached from the Activity | ||
private lateinit var channel: MethodChannel | ||
|
||
private var mActivity: Activity? = null | ||
|
||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "clickstream_flutter") | ||
channel.setMethodCallHandler(this) | ||
} | ||
|
||
override fun onMethodCall(call: MethodCall, result: Result) { | ||
if (call.method == "getPlatformVersion") { | ||
result.success("Android ${android.os.Build.VERSION.RELEASE}") | ||
} else if (call.method == "init") { | ||
if (mActivity != null) { | ||
ClickstreamAnalytics.init(mActivity!!.applicationContext) | ||
ClickstreamAnalytics.getClickStreamConfiguration() | ||
.withAppId("shopping") | ||
.withEndpoint("http://Clicks-Inges-m6f4WJ0DDSWv-478806672.us-east-1.elb.amazonaws.com/collect") | ||
.withLogEvents(true) | ||
result.success(true) | ||
} else { | ||
result.success(false) | ||
} | ||
} else if (call.method == "record") { | ||
ClickstreamAnalytics.recordEvent(call.arguments.toString()) | ||
} else { | ||
result.notImplemented() | ||
} | ||
} | ||
|
||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
channel.setMethodCallHandler(null) | ||
} | ||
} | ||
|
||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { | ||
channel.setMethodCallHandler(null) | ||
} | ||
override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
mActivity = binding.activity | ||
} | ||
|
||
override fun onDetachedFromActivityForConfigChanges() { | ||
} | ||
|
||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
mActivity = binding.activity | ||
} | ||
|
||
override fun onDetachedFromActivity() { | ||
mActivity = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"UserAgent": "aws-solution/clickstream", | ||
"Version": "1.0", | ||
"analytics": { | ||
"plugins": { | ||
"awsClickstreamPlugin": { | ||
"appId": "", | ||
"endpoint": "", | ||
"isCompressEvents": true, | ||
"autoFlushEventsInterval": 10000, | ||
"isTrackAppExceptionEvents": false | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Generated file. | ||
// | ||
// If you wish to remove Flutter's multidex support, delete this entire file. | ||
// | ||
// Modifications to this file should be done in a copy under a different name | ||
// as this file may be regenerated. | ||
|
||
package io.flutter.app; | ||
|
||
import android.app.Application; | ||
import android.content.Context; | ||
import androidx.annotation.CallSuper; | ||
import androidx.multidex.MultiDex; | ||
|
||
/** | ||
* Extension of {@link android.app.Application}, adding multidex support. | ||
*/ | ||
public class FlutterMultiDexApplication extends Application { | ||
@Override | ||
@CallSuper | ||
protected void attachBaseContext(Context base) { | ||
super.attachBaseContext(base); | ||
MultiDex.install(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
PODS: | ||
- clickstream_flutter (0.0.1): | ||
- Flutter | ||
- Flutter (1.0.0) | ||
- integration_test (0.0.1): | ||
- Flutter | ||
|
||
DEPENDENCIES: | ||
- clickstream_flutter (from `.symlinks/plugins/clickstream_flutter/ios`) | ||
- Flutter (from `Flutter`) | ||
- integration_test (from `.symlinks/plugins/integration_test/ios`) | ||
|
||
EXTERNAL SOURCES: | ||
clickstream_flutter: | ||
:path: ".symlinks/plugins/clickstream_flutter/ios" | ||
Flutter: | ||
:path: Flutter | ||
integration_test: | ||
:path: ".symlinks/plugins/integration_test/ios" | ||
|
||
SPEC CHECKSUMS: | ||
clickstream_flutter: 2df0c1ea137129668289dc8ab4d4a1394ee246b9 | ||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 | ||
integration_test: 13825b8a9334a850581300559b8839134b124670 | ||
|
||
PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 | ||
|
||
COCOAPODS: 1.13.0 |
Oops, something went wrong.