Skip to content

Commit 4266640

Browse files
authored
feat: Passthrough SDK wrapper type to native SDKs (#51)
1 parent de864ac commit 4266640

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

android/src/main/kotlin/com/mparticle/mparticle_flutter_sdk/MparticleFlutterSdkPlugin.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.mparticle.mparticle_flutter_sdk
22

33
import androidx.annotation.NonNull
4-
import android.util.Log
54

65
import io.flutter.embedding.engine.plugins.FlutterPlugin
76
import io.flutter.plugin.common.MethodCall
@@ -18,6 +17,7 @@ import com.mparticle.identity.MParticleUser
1817
import com.mparticle.MParticle
1918
import com.mparticle.MPEvent
2019
import com.mparticle.UserAttributeListener
20+
import com.mparticle.WrapperSdk
2121
import com.mparticle.commerce.*
2222
import com.mparticle.consent.CCPAConsent
2323
import com.mparticle.consent.ConsentState
@@ -213,6 +213,10 @@ class MparticleFlutterSdkPlugin: FlutterPlugin, MethodCallHandler {
213213
}
214214
result.success(true)
215215
}
216+
"setSdkVersion" -> {
217+
setSdkVersion()
218+
result.success(true)
219+
}
216220
"roktSelectPlacements" -> this.roktSelectPlacements(call, result)
217221
else -> {
218222
result.notImplemented()
@@ -876,6 +880,13 @@ class MparticleFlutterSdkPlugin: FlutterPlugin, MethodCallHandler {
876880
}
877881
}
878882

883+
private fun setSdkVersion() {
884+
MParticle.getInstance()?.let { instance ->
885+
// Version string deliberately left blank
886+
instance.setWrapperSdk(WrapperSdk.WrapperFlutter, "")
887+
}
888+
}
889+
879890
companion object {
880891
private const val VIEW_TYPE = "rokt_sdk.rokt.com/rokt_layout"
881892
}

example/ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ target 'Runner' do
3333

3434
pod 'mParticle-Apple-SDK'
3535
pod 'mParticle-Rokt'
36+
3637
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3738
end
3839

ios/Classes/SwiftMparticleFlutterSdkPlugin.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ public class SwiftMparticleFlutterSdkPlugin: NSObject, FlutterPlugin {
498498
} else {
499499
print("Incorrect argument for \(call.method) iOS method")
500500
}
501+
case "setSdkVersion":
502+
MParticle._setWrapperSdk_internal(MPWrapperSdk.flutter, version: "")
501503
case "roktSelectPlacements":
502504
if let callArguments = call.arguments as? [String: Any],
503505
let placementId = callArguments["placementId"] as? String {

lib/mparticle_flutter_sdk.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MparticleFlutterSdk {
3939
if (_instance == null) {
4040
if (await _channel.invokeMethod('isInitialized') == true) {
4141
_instance = new MparticleFlutterSdk();
42+
_instance!._setSdkVersion();
4243
}
4344
}
4445
return _instance;
@@ -213,6 +214,10 @@ class MparticleFlutterSdk {
213214
Map attributionsMap = jsonDecode(attributionsString);
214215
return attributionsMap;
215216
}
217+
218+
Future<void> _setSdkVersion() async {
219+
return await _channel.invokeMethod('setSdkVersion');
220+
}
216221
}
217222

218223
/// An object that contains identities that are passed to [identity] calls

0 commit comments

Comments
 (0)