Skip to content

Commit 4ad6a4a

Browse files
Merge pull request #125 from qonversion/feature/deprecatedUserId
Deprecated setUserId method
2 parents 0d76bd1 + 9050abe commit 4ad6a4a

File tree

11 files changed

+18
-37
lines changed

11 files changed

+18
-37
lines changed

android/build.gradle

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

44
buildscript {
55
ext.kotlin_version = '1.3.50'
6-
ext.qonversion_version = '2.11.1'
6+
ext.qonversion_version = '2.11.7'
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
@@ -4,7 +4,7 @@ import android.app.Activity
44
import android.app.Application
55
import android.util.Log
66
import androidx.annotation.NonNull
7-
import androidx.preference.PreferenceManager
7+
import android.preference.PreferenceManager
88
import com.google.gson.Gson
99
import com.google.gson.JsonSyntaxException
1010
import com.qonversion.android.sdk.*
@@ -108,7 +108,6 @@ class QonversionFlutterSdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAwa
108108
"purchaseProduct" -> purchaseProduct(args["product"] as? String, result)
109109
"updatePurchase" -> updatePurchase(args, result)
110110
"updatePurchaseWithProduct" -> updatePurchaseWithProduct(args, result)
111-
"setUserId" -> setUserId(args["userId"] as? String, result)
112111
"setProperty" -> setProperty(args, result)
113112
"setUserProperty" -> setUserProperty(args, result)
114113
"addAttributionData" -> addAttributionData(args, result)
@@ -275,16 +274,6 @@ class QonversionFlutterSdkPlugin : MethodCallHandler, FlutterPlugin, ActivityAwa
275274
})
276275
}
277276

278-
private fun setUserId(userId: String?, result: Result) {
279-
if (userId == null) {
280-
result.noUserIdError()
281-
return
282-
}
283-
284-
Qonversion.setUserID(userId)
285-
result.success(null)
286-
}
287-
288277
private fun setProperty(args: Map<String, Any>, result: Result) {
289278
val rawProperty = args["property"] as? String ?: return result.noProperty()
290279

example/lib/home.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ class _HomeViewState extends State<HomeView> {
4747
Padding(
4848
padding: const EdgeInsets.all(8.0),
4949
child: FlatButton(
50-
child: Text('Set custom userId'),
51-
color: Colors.blue,
52-
textColor: Colors.white,
53-
onPressed: () => Qonversion.setUserId('userId'),
54-
),
50+
child: Text('Set custom userId'),
51+
color: Colors.blue,
52+
textColor: Colors.white,
53+
onPressed: () => Qonversion.setProperty(
54+
QUserProperty.customUserId, 'userId')),
5555
),
5656
Padding(
5757
padding: const EdgeInsets.only(

example/lib/params_view.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class ParamsView extends StatelessWidget {
2121
child: Text('Set User ID'),
2222
color: Colors.green,
2323
textColor: Colors.white,
24-
onPressed: () async {
25-
await Qonversion.setUserId('customId');
24+
onPressed: () {
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
@@ -95,6 +95,9 @@ extension Qonversion.Property {
9595
case "KochavaDeviceId":
9696
return .kochavaDeviceID
9797

98+
case "CustomUserId":
99+
return .userID
100+
98101
default:
99102
throw ParsingError.runtimeError("Could not parse Qonversion.Property")
100103
}

ios/Classes/SwiftQonversionFlutterSdkPlugin.swift

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

88-
case "setUserId":
89-
return setUserId(args["userId"] as? String, result)
90-
9188
case "addAttributionData":
9289
return addAttributionData(args, result)
9390

@@ -249,16 +246,6 @@ public class SwiftQonversionFlutterSdkPlugin: NSObject, FlutterPlugin {
249246
}
250247
}
251248

252-
private func setUserId(_ userId: String?, _ result: @escaping FlutterResult) {
253-
guard let userId = userId else {
254-
result(FlutterError.noUserId)
255-
return
256-
}
257-
258-
Qonversion.setUserID(userId)
259-
result(nil)
260-
}
261-
262249
private func setProperty(_ args: [String: Any], _ result: @escaping FlutterResult) {
263250
guard let rawProperty = args["property"] as? String else {
264251
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.17.1'
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
@@ -27,7 +27,6 @@ class Constants {
2727
static const mUpdatePurchaseWithProduct = 'updatePurchaseWithProduct';
2828
static const mCheckPermissions = 'checkPermissions';
2929
static const mRestore = 'restore';
30-
static const mSetUserId = 'setUserId';
3130
static const mSetProperty = 'setProperty';
3231
static const mSetUserProperty = 'setUserProperty';
3332
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)