Skip to content

Commit 5b81001

Browse files
Merge pull request #130 from qonversion/feature/deprecatedUserId_dev
Deprecated setUserId method (dev)
2 parents f27d496 + 6cd5a2e commit 5b81001

File tree

11 files changed

+17
-36
lines changed

11 files changed

+17
-36
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version '4.2.0'
33

44
buildscript {
55
ext.kotlin_version = '1.3.50'
6-
ext.qonversion_version = '3.2.2'
6+
ext.qonversion_version = '3.2.4'
77
repositories {
88
google()
99
jcenter()

android/src/main/kotlin/com/qonversion/flutter/sdk/qonversion_flutter_sdk/QonversionFlutterSdkPlugin.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class QonversionFlutterSdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAwa
109109
"purchaseProduct" -> purchaseProduct(args["product"] as? String, result)
110110
"updatePurchase" -> updatePurchase(args, result)
111111
"updatePurchaseWithProduct" -> updatePurchaseWithProduct(args, result)
112-
"setUserId" -> setUserId(args["userId"] as? String, result)
113112
"setProperty" -> setProperty(args, result)
114113
"setUserProperty" -> setUserProperty(args, result)
115114
"addAttributionData" -> addAttributionData(args, result)
@@ -280,16 +279,6 @@ class QonversionFlutterSdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAwa
280279
})
281280
}
282281

283-
private fun setUserId(userId: String?, result: Result) {
284-
if (userId == null) {
285-
result.noUserIdError()
286-
return
287-
}
288-
289-
Qonversion.setUserID(userId)
290-
result.success(null)
291-
}
292-
293282
private fun setProperty(args: Map<String, Any>, result: Result) {
294283
val rawProperty = args["property"] as? String ?: return result.noProperty()
295284

@@ -365,7 +354,7 @@ class QonversionFlutterSdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAwa
365354
if (data.isEmpty()) {
366355
return result.noDataError()
367356
}
368-
357+
369358
val stringsMap: Map<String, String> = data.mapValues { it.value.toString() }
370359
val isQonversionNotification = Qonversion.handleNotification(stringsMap)
371360
result.success(isQonversionNotification)

example/lib/home.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ class _HomeViewState extends State<HomeView> {
9595
Padding(
9696
padding: const EdgeInsets.all(8.0),
9797
child: FlatButton(
98-
child: Text('Set custom userId'),
99-
color: Colors.blue,
100-
textColor: Colors.white,
101-
onPressed: () => Qonversion.setUserId('userId'),
102-
),
98+
child: Text('Set custom userId'),
99+
color: Colors.blue,
100+
textColor: Colors.white,
101+
onPressed: () => Qonversion.setProperty(
102+
QUserProperty.customUserId, 'userId')),
103103
),
104104
Padding(
105105
padding: const EdgeInsets.only(

example/lib/params_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ParamsView extends StatelessWidget {
2222
color: Colors.green,
2323
textColor: Colors.white,
2424
onPressed: () {
25-
Qonversion.setUserId('customId');
25+
Qonversion.setProperty(QUserProperty.customUserId, 'customId');
2626
print('did set user id');
2727
},
2828
),

ios/Classes/Mapper.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ extension Qonversion.Property {
118118
case "KochavaDeviceId":
119119
return .kochavaDeviceID
120120

121+
case "CustomUserId":
122+
return .userID
123+
121124
default:
122125
throw ParsingError.runtimeError("Could not parse Qonversion.Property")
123126
}

ios/Classes/SwiftQonversionFlutterSdkPlugin.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ public class SwiftQonversionFlutterSdkPlugin: NSObject, FlutterPlugin {
9090
case "promoPurchase":
9191
return promoPurchase(args["productId"] as? String, result)
9292

93-
case "setUserId":
94-
return setUserId(args["userId"] as? String, result)
95-
9693
case "addAttributionData":
9794
return addAttributionData(args, result)
9895

@@ -264,16 +261,6 @@ public class SwiftQonversionFlutterSdkPlugin: NSObject, FlutterPlugin {
264261
}
265262
}
266263

267-
private func setUserId(_ userId: String?, _ result: @escaping FlutterResult) {
268-
guard let userId = userId else {
269-
result(FlutterError.noUserId)
270-
return
271-
}
272-
273-
Qonversion.setUserID(userId)
274-
result(nil)
275-
}
276-
277264
private func setProperty(_ args: [String: Any], _ result: @escaping FlutterResult) {
278265
guard let rawProperty = args["property"] as? String else {
279266
return result(FlutterError.noProperty)

ios/qonversion_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
s.source_files = 'Classes/**/*'
1717
s.dependency 'Flutter'
1818
s.platform = :ios, '9.0'
19-
s.dependency 'Qonversion', '2.18.0'
19+
s.dependency 'Qonversion', '2.18.1'
2020

2121
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
2222
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }

lib/src/constants.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Constants {
3030
static const mUpdatePurchaseWithProduct = 'updatePurchaseWithProduct';
3131
static const mCheckPermissions = 'checkPermissions';
3232
static const mRestore = 'restore';
33-
static const mSetUserId = 'setUserId';
3433
static const mSetProperty = 'setProperty';
3534
static const mSetUserProperty = 'setUserProperty';
3635
static const mSyncPurchases = 'syncPurchases';

lib/src/models/user_property.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ enum QUserProperty {
44
appsFlyerUserId,
55
adjustAdId,
66
kochavaDeviceId,
7+
customUserId,
78
}

lib/src/qonversion.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ class Qonversion {
209209
/// Qonversion SDK provides an asynchronous method to set your side User ID that can be used to match users in third-party integrations.
210210
///
211211
/// See more in [documentation](https://documentation.qonversion.io/docs/user-identifiers)
212+
@Deprecated(
213+
"Will be removed in a future major release. Use setProperty(QUserProperty.customUserId, 'value') instead.")
212214
static Future<void> setUserId(String userId) =>
213-
_channel.invokeMethod(Constants.mSetUserId, {Constants.kUserId: userId});
215+
setProperty(QUserProperty.customUserId, userId);
214216

215217
/// Sets user property for pre-defined case property.
216218
///

0 commit comments

Comments
 (0)