-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathadjust.dart
192 lines (153 loc) · 5.71 KB
/
adjust.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// adjust_sdk.dart
// Adjust SDK
//
// Created by Srdjan Tubin (@2beens) on 25th April 2018.
// Copyright (c) 2018-Present Adjust GmbH. All rights reserved.
//
import 'dart:async';
import 'package:adjust_sdk/adjust_ad_revenue.dart';
import 'package:adjust_sdk/adjust_app_store_subscription.dart';
import 'package:adjust_sdk/adjust_attribution.dart';
import 'package:adjust_sdk/adjust_config.dart';
import 'package:adjust_sdk/adjust_event.dart';
import 'package:adjust_sdk/adjust_play_store_subscription.dart';
import 'package:adjust_sdk/adjust_third_party_sharing.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
class Adjust {
static const String _sdkPrefix = 'flutter4.30.0';
static const MethodChannel _channel =
const MethodChannel('com.adjust.sdk/api');
static void start(AdjustConfig config) {
config.sdkPrefix = _sdkPrefix;
_channel.invokeMethod('start', config.toMap);
}
static void trackEvent(AdjustEvent event) {
_channel.invokeMethod('trackEvent', event.toMap);
}
static void setEnabled(bool isEnabled) {
_channel.invokeMethod('setEnabled', {'isEnabled': isEnabled});
}
static void setOfflineMode(bool isOffline) {
_channel.invokeMethod('setOfflineMode', {'isOffline': isOffline});
}
static void setPushToken(String token) {
_channel.invokeMethod('setPushToken', {'pushToken': token});
}
static void setReferrer(String referrer) {
_channel.invokeMethod('setReferrer', {'referrer': referrer});
}
static void appWillOpenUrl(String url) {
_channel.invokeMethod('appWillOpenUrl', {'url': url});
}
static void sendFirstPackages() {
_channel.invokeMethod('sendFirstPackages');
}
static void gdprForgetMe() {
_channel.invokeMethod('gdprForgetMe');
}
static void disableThirdPartySharing() {
_channel.invokeMethod('disableThirdPartySharing');
}
static void onResume() {
_channel.invokeMethod('onResume');
}
static void onPause() {
_channel.invokeMethod('onPause');
}
static Future<bool> isEnabled() async {
final bool isEnabled = await _channel.invokeMethod('isEnabled');
return isEnabled;
}
static Future<String?> getAdid() async {
final String? adid = await _channel.invokeMethod('getAdid');
return adid;
}
static Future<String?> getIdfa() async {
final String? idfa = await _channel.invokeMethod('getIdfa');
return idfa;
}
static Future<String?> getAmazonAdId() async {
final String? amazonAdId = await _channel.invokeMethod('getAmazonAdId');
return amazonAdId;
}
static Future<String?> getGoogleAdId() async {
final String? googleAdId = await _channel.invokeMethod('getGoogleAdId');
return googleAdId;
}
static Future<num> requestTrackingAuthorizationWithCompletionHandler() async {
final num status = await _channel
.invokeMethod('requestTrackingAuthorizationWithCompletionHandler');
return status;
}
static Future<int> getAppTrackingAuthorizationStatus() async {
final int authorizationStatus =
await _channel.invokeMethod('getAppTrackingAuthorizationStatus');
return authorizationStatus;
}
static Future<AdjustAttribution> getAttribution() async {
final dynamic attributionMap =
await _channel.invokeMethod('getAttribution');
return AdjustAttribution.fromMap(attributionMap);
}
static Future<String> getSdkVersion() async {
final String sdkVersion = await _channel.invokeMethod('getSdkVersion');
return _sdkPrefix + '@' + sdkVersion;
}
static void addSessionCallbackParameter(String key, String value) {
_channel.invokeMethod(
'addSessionCallbackParameter', {'key': key, 'value': value});
}
static void addSessionPartnerParameter(String key, String value) {
_channel.invokeMethod(
'addSessionPartnerParameter', {'key': key, 'value': value});
}
static void removeSessionCallbackParameter(String key) {
_channel.invokeMethod('removeSessionCallbackParameter', {'key': key});
}
static void removeSessionPartnerParameter(String key) {
_channel.invokeMethod('removeSessionPartnerParameter', {'key': key});
}
static void resetSessionCallbackParameters() {
_channel.invokeMethod('resetSessionCallbackParameters');
}
static void resetSessionPartnerParameters() {
_channel.invokeMethod('resetSessionPartnerParameters');
}
static void trackAdRevenue(String source, String payload) {
_channel
.invokeMethod('trackAdRevenue', {'source': source, 'payload': payload});
}
static void trackAdRevenueNew(AdjustAdRevenue adRevenue) {
_channel.invokeMethod('trackAdRevenueNew', adRevenue.toMap);
}
static void trackAppStoreSubscription(
AdjustAppStoreSubscription subscription) {
_channel.invokeMethod('trackAppStoreSubscription', subscription.toMap);
}
static void trackPlayStoreSubscription(
AdjustPlayStoreSubscription subscription) {
_channel.invokeMethod('trackPlayStoreSubscription', subscription.toMap);
}
static void trackThirdPartySharing(
AdjustThirdPartySharing thirdPartySharing) {
_channel.invokeMethod('trackThirdPartySharing', thirdPartySharing.toMap);
}
static void trackMeasurementConsent(bool measurementConsent) {
_channel.invokeMethod(
'trackMeasurementConsent', {'measurementConsent': measurementConsent});
}
static void updateConversionValue(int conversionValue) {
_channel.invokeMethod(
'updateConversionValue', {'conversionValue': conversionValue});
}
static void checkForNewAttStatus() {
_channel.invokeMethod('checkForNewAttStatus');
}
// For testing purposes only. Do not use in production.
@visibleForTesting
static void setTestOptions(final dynamic testOptions) {
_channel.invokeMethod('setTestOptions', testOptions);
}
}