Skip to content

Commit 2fb898c

Browse files
committed
remove old launch method, use launch instead of initialize now
1 parent 0ba534a commit 2fb898c

File tree

4 files changed

+5
-59
lines changed

4 files changed

+5
-59
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 1.0.0
22

3-
* API update: new `initialize` method with just one API key argument for both platforms; deprecate `launch` method; remove all old `launch...` methods.
3+
* API update: new `launch` method with just one API key argument for both platforms; remove old `launch` method; remove all old `launch...` methods.
44
* Add `trackPurchase` method to track Android purchases manually.
55
* Add `addAttributionData` method implementation for Android.
66

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void initState() {
4545
}
4646
4747
Future<String> _launchQonversion() async {
48-
_qonversionUserId = await Qonversion.initialize('YOUR_API_KEY');
48+
_qonversionUserId = await Qonversion.launch('YOUR_API_KEY');
4949
}
5050
5151
...
@@ -61,7 +61,7 @@ You can also specify your client side `userId` (instead of Qonversion user-id) t
6161

6262
```
6363
final userId = 'CLIENT_SIDE_USER_ID';
64-
Qonversion.initialize(
64+
Qonversion.launch(
6565
'YOUR_API_KEY',
6666
userId: userId,
6767
);

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class _MyAppState extends State<MyApp> {
2222
Future<void> initPlatformState() async {
2323
String uid;
2424
try {
25-
uid = await Qonversion.initialize('');
25+
uid = await Qonversion.launch('');
2626
print(uid);
2727
} catch (e) {
2828
print('Failed to obtain uid from Qonversion.');

lib/src/qonversion.dart

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Qonversion {
2626
/// You can provide your own client-side [userId] if needed.
2727
///
2828
/// Returns `userId` for Ads integrations.
29-
static Future<String> initialize(
29+
static Future<String> launch(
3030
String apiKey, {
3131
String userId,
3232
}) async {
@@ -40,38 +40,6 @@ class Qonversion {
4040
return uid;
4141
}
4242

43-
/// Launches Qonversion SDK with the given API keys for each platform:
44-
/// [androidApiKey] and [iosApiKey] respectively,
45-
/// you can get one in your account on qonversion.io.
46-
///
47-
/// Returns `userId` for Ads integrations.
48-
///
49-
/// **Warning**:
50-
/// On iOS Qonversion will track any purchase events (trials, subscriptions, basic purchases) automatically.
51-
///
52-
/// On Android you will have to call `Qonversion.trackPurchase(details, purchase)` method to track all
53-
/// purchases manually.
54-
@Deprecated('Use Qonversion.initialize with just one API key instead')
55-
static Future<String> launch({
56-
@required String androidApiKey,
57-
@required String iosApiKey,
58-
String userId,
59-
}) async {
60-
final apiKey = _obtainPlatformApiKey(
61-
androidApiKey: androidApiKey,
62-
iosApiKey: iosApiKey,
63-
);
64-
65-
final args = {
66-
Constants.kApiKey: apiKey,
67-
Constants.kUserId: userId,
68-
};
69-
70-
final uid = await _channel.invokeMethod(Constants.mLaunch, args);
71-
72-
return uid;
73-
}
74-
7543
/// Tracks purchases manually on Android.
7644
///
7745
/// Returns `null` if `!Platform.isAndroid`.
@@ -113,26 +81,4 @@ class Qonversion {
11381

11482
return _channel.invokeMethod(Constants.mAddAttributionData, args);
11583
}
116-
117-
static String _obtainPlatformApiKey({
118-
String androidApiKey,
119-
String iosApiKey,
120-
}) {
121-
String key;
122-
123-
if (Platform.isAndroid) {
124-
key = androidApiKey;
125-
} else if (Platform.isIOS) {
126-
key = iosApiKey;
127-
} else {
128-
throw Exception('Unsupported platform');
129-
}
130-
131-
if (key == null) {
132-
throw Exception(
133-
'Please provide API key for the platform you are running an app on');
134-
}
135-
136-
return key;
137-
}
13884
}

0 commit comments

Comments
 (0)