indigitall-capacitor-plugin 2.0.6 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/IndigitallCapacitorPlugin.podspec +1 -1
- package/README.md +28 -4
- package/android/build.gradle +3 -3
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/indigitall/capacitor/IndigitallCpPlugin.java +45 -57
- package/android/src/main/java/com/indigitall/capacitor/IndigitallInAppPlugin.java +104 -46
- package/android/src/main/java/com/indigitall/capacitor/implementations/CustomerCp.java +7 -7
- package/android/src/main/java/com/indigitall/capacitor/implementations/InAppCp.java +52 -13
- package/android/src/main/java/com/indigitall/capacitor/implementations/IndigitallCp.java +88 -23
- package/android/src/main/java/com/indigitall/capacitor/models/CpIndigitallHiddenActivity.java +3 -3
- package/android/src/main/java/com/indigitall/capacitor/models/CpPushNotification.java +12 -7
- package/android/src/main/java/com/indigitall/capacitor/services/IndigitallFirebaseMessagingService.java +3 -3
- package/android/src/main/java/com/indigitall/capacitor/utils/CpIndigitallUtils.java +4 -4
- package/android/src/main/java/com/indigitall/capacitor/utils/IndigitallInAppParse.java +49 -32
- package/android/src/main/java/com/indigitall/capacitor/utils/IndigitallParse.java +15 -82
- package/dist/docs.json +22 -2
- package/dist/esm/InApp.js +290 -85
- package/dist/esm/InApp.js.map +1 -1
- package/dist/esm/Push.js +11 -3
- package/dist/esm/Push.js.map +1 -1
- package/dist/esm/callbacks/callbacksType.d.ts +4 -1
- package/dist/esm/callbacks/callbacksType.js.map +1 -1
- package/dist/esm/definitions/customerDefinitions.d.ts +2 -2
- package/dist/esm/definitions/customerDefinitions.js.map +1 -1
- package/dist/esm/definitions/inAppDefinitions.d.ts +13 -3
- package/dist/esm/definitions/inAppDefinitions.js.map +1 -1
- package/dist/esm/definitions/pushDefinitions.d.ts +7 -3
- package/dist/esm/definitions/pushDefinitions.js.map +1 -1
- package/dist/esm/models/InInApp.d.ts +1 -1
- package/dist/esm/models/InInApp.js.map +1 -1
- package/dist/esm/models/InInbox.d.ts +1 -1
- package/dist/esm/models/InInbox.js.map +1 -1
- package/dist/esm/params/customerParams.d.ts +1 -1
- package/dist/esm/params/customerParams.js.map +1 -1
- package/dist/esm/params/pushParams.d.ts +2 -0
- package/dist/esm/params/pushParams.js.map +1 -1
- package/dist/plugin.cjs.js +300 -88
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +300 -88
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/IndigitallCpPlugin.swift +11 -1
- package/ios/Plugin/implementations/CustomerCp.swift +1 -3
- package/ios/Plugin/implementations/InAppCp.swift +7 -24
- package/ios/Plugin/implementations/InboxCp.swift +9 -9
- package/ios/Plugin/implementations/IndigitallCp.swift +25 -3
- package/ios/Plugin/utils/IndigitallParse.h +1 -2
- package/ios/Plugin/utils/IndigitallParse.m +41 -21
- package/package.json +1 -1
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '12.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'indigitall-ios', '~>
|
|
16
|
+
s.dependency 'indigitall-ios', '~> 6.2.0'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
end
|
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ npx cap sync
|
|
|
13
13
|
|
|
14
14
|
<docgen-index>
|
|
15
15
|
|
|
16
|
+
* [`requestPushPermission()`](#requestpushpermission)
|
|
17
|
+
* [`getPushPermissionStatus()`](#getpushpermissionstatus)
|
|
16
18
|
* [`initialize(...)`](#initialize)
|
|
17
19
|
* [`deviceGet()`](#deviceget)
|
|
18
20
|
* [`deviceEnable()`](#deviceenable)
|
|
@@ -38,6 +40,28 @@ npx cap sync
|
|
|
38
40
|
<docgen-api>
|
|
39
41
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
40
42
|
|
|
43
|
+
### requestPushPermission()
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
requestPushPermission() => Promise<any>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Returns:** <code>Promise<any></code>
|
|
50
|
+
|
|
51
|
+
--------------------
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### getPushPermissionStatus()
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
getPushPermissionStatus() => Promise<any>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Returns:** <code>Promise<any></code>
|
|
61
|
+
|
|
62
|
+
--------------------
|
|
63
|
+
|
|
64
|
+
|
|
41
65
|
### initialize(...)
|
|
42
66
|
|
|
43
67
|
```typescript
|
|
@@ -238,12 +262,12 @@ isIndigitallPushNotification(params: { notification: any; }) => Promise<any>
|
|
|
238
262
|
### logIn(...)
|
|
239
263
|
|
|
240
264
|
```typescript
|
|
241
|
-
logIn(param: {
|
|
265
|
+
logIn(param: { externalCode: string; }) => Promise<any>
|
|
242
266
|
```
|
|
243
267
|
|
|
244
|
-
| Param | Type
|
|
245
|
-
| ----------- |
|
|
246
|
-
| **`param`** | <code>{
|
|
268
|
+
| Param | Type |
|
|
269
|
+
| ----------- | -------------------------------------- |
|
|
270
|
+
| **`param`** | <code>{ externalCode: string; }</code> |
|
|
247
271
|
|
|
248
272
|
**Returns:** <code>Promise<any></code>
|
|
249
273
|
|
package/android/build.gradle
CHANGED
|
@@ -19,10 +19,10 @@ apply plugin: 'com.android.library'
|
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
21
|
namespace "com.indigitall.capacitor"
|
|
22
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
22
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
|
|
23
23
|
defaultConfig {
|
|
24
24
|
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
|
|
26
26
|
versionCode 1
|
|
27
27
|
versionName "1.0"
|
|
28
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -56,7 +56,7 @@ dependencies {
|
|
|
56
56
|
testImplementation "junit:junit:$junitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
58
58
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
59
|
-
implementation('com.indigitall:android:5.
|
|
59
|
+
implementation('com.indigitall:android:5.5.+'){
|
|
60
60
|
exclude group: "com.indigitall", module: "android-hms"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
</queries>
|
|
15
15
|
<application
|
|
16
16
|
android:allowBackup="true">
|
|
17
|
-
<service android:name="com.indigitall.android.services.StatisticService" />
|
|
18
|
-
<receiver android:name="com.indigitall.android.receivers.BootReceiver"
|
|
17
|
+
<service android:name="com.indigitall.android.push.services.StatisticService" />
|
|
18
|
+
<receiver android:name="com.indigitall.android.push.receivers.BootReceiver"
|
|
19
19
|
android:exported="false">
|
|
20
20
|
<intent-filter>
|
|
21
21
|
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.indigitall.capacitor;
|
|
2
2
|
|
|
3
3
|
import android.Manifest;
|
|
4
|
+
import android.app.Activity;
|
|
4
5
|
import android.content.Context;
|
|
5
6
|
import android.content.Intent;
|
|
6
7
|
import android.content.pm.PackageManager;
|
|
@@ -10,6 +11,7 @@ import android.os.Handler;
|
|
|
10
11
|
import android.util.Log;
|
|
11
12
|
|
|
12
13
|
import androidx.annotation.NonNull;
|
|
14
|
+
import androidx.core.app.ActivityCompat;
|
|
13
15
|
|
|
14
16
|
import com.getcapacitor.JSArray;
|
|
15
17
|
import com.getcapacitor.JSObject;
|
|
@@ -18,18 +20,19 @@ import com.getcapacitor.PluginCall;
|
|
|
18
20
|
import com.getcapacitor.PluginMethod;
|
|
19
21
|
import com.getcapacitor.PluginResult;
|
|
20
22
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
21
|
-
import com.indigitall.android.
|
|
22
|
-
import com.indigitall.android.callbacks.
|
|
23
|
-
import com.indigitall.android.callbacks.
|
|
24
|
-
import com.indigitall.android.callbacks.
|
|
25
|
-
import com.indigitall.android.callbacks.
|
|
23
|
+
import com.indigitall.android.Indigitall;
|
|
24
|
+
import com.indigitall.android.push.callbacks.DeviceCallback;
|
|
25
|
+
import com.indigitall.android.push.callbacks.EventCallback;
|
|
26
|
+
import com.indigitall.android.push.callbacks.InitCallBack;
|
|
27
|
+
import com.indigitall.android.push.callbacks.PushTokenCallback;
|
|
28
|
+
import com.indigitall.android.push.callbacks.TopicsCallback;
|
|
26
29
|
import com.indigitall.android.commons.models.ErrorModel;
|
|
27
|
-
import com.indigitall.android.models.Device;
|
|
28
|
-
import com.indigitall.android.models.Permission;
|
|
29
|
-
import com.indigitall.android.models.Push;
|
|
30
|
-
import com.indigitall.android.models.PushErrorModel;
|
|
31
|
-
import com.indigitall.android.models.Topic;
|
|
32
|
-
import com.indigitall.android.utils.FirebaseUtils;
|
|
30
|
+
import com.indigitall.android.push.models.Device;
|
|
31
|
+
import com.indigitall.android.push.models.Permission;
|
|
32
|
+
import com.indigitall.android.push.models.Push;
|
|
33
|
+
import com.indigitall.android.push.models.PushErrorModel;
|
|
34
|
+
import com.indigitall.android.push.models.Topic;
|
|
35
|
+
import com.indigitall.android.push.utils.FirebaseUtils;
|
|
33
36
|
import com.indigitall.capacitor.interfaces.IndigitallFirebaseInterface;
|
|
34
37
|
import com.indigitall.capacitor.utils.CpPreferenceUtils;
|
|
35
38
|
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
@@ -53,59 +56,44 @@ public class IndigitallCpPlugin extends Plugin implements IndigitallFirebaseInte
|
|
|
53
56
|
public static IndigitallFirebaseInterface indigitallInterface;
|
|
54
57
|
public static PluginCall getPushCallback;
|
|
55
58
|
|
|
59
|
+
@PluginMethod
|
|
60
|
+
public void getPushPermissionStatus(PluginCall call) {
|
|
61
|
+
IndigitallCp.getPushPermissionStatus(getContext(), call);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@PluginMethod
|
|
65
|
+
public void requestPushPermission(PluginCall call) {
|
|
66
|
+
IndigitallCp.requestPushPermission(getContext());
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
@PluginMethod
|
|
57
70
|
public void initialize(PluginCall call) {
|
|
58
|
-
final String JSON_REQUEST_LOCATION = "requestLocation";
|
|
59
71
|
String CONFIG = "config";
|
|
60
72
|
JSObject obj = call.getObject(CONFIG);
|
|
61
|
-
boolean requestLocation = false;
|
|
62
|
-
if (obj != null) {
|
|
63
|
-
try {
|
|
64
|
-
if (obj.has(JSON_REQUEST_LOCATION)) {
|
|
65
|
-
requestLocation = obj.getBoolean(JSON_REQUEST_LOCATION);
|
|
66
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
67
|
-
if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
|
|
68
|
-
PackageManager.PERMISSION_GRANTED) {
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} catch (NullPointerException | JSONException ex) {
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
// if (requestLocation){
|
|
77
|
-
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
78
|
-
// if (cordova.getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
|
|
79
|
-
// PackageManager.PERMISSION_GRANTED ){
|
|
80
|
-
// cordova.requestPermission(this, REQUEST_CODE_ASK_PERMISSIONS, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
81
|
-
// }
|
|
82
|
-
// }
|
|
83
|
-
// }
|
|
84
|
-
IndigitallCp.initialize(getContext(), getActivity().getClass().getName(), obj, new InitCallBack(getContext()) {
|
|
85
|
-
|
|
86
|
-
@Override
|
|
87
|
-
public void onErrorInitialized(ErrorModel errorModel) {
|
|
88
|
-
call.reject(errorModel.getErrorMessage().getErrorMessage());
|
|
89
|
-
}
|
|
74
|
+
IndigitallCp.initialize(getContext(), getActivity(), obj, new InitCallBack(getContext()) {
|
|
90
75
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
call.resolve(ret);
|
|
96
|
-
}
|
|
76
|
+
@Override
|
|
77
|
+
public void onErrorInitialized(ErrorModel errorModel) {
|
|
78
|
+
call.reject(errorModel.getErrorMessage().getErrorMessage());
|
|
79
|
+
}
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
call.resolve(ret);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
81
|
+
@Override
|
|
82
|
+
public void onNewUserRegistered(Device device) {
|
|
83
|
+
JSObject ret = new JSObject();
|
|
84
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
85
|
+
call.resolve(ret);
|
|
86
|
+
}
|
|
107
87
|
|
|
108
|
-
|
|
88
|
+
@Override
|
|
89
|
+
public void onIndigitallInitialized(Permission[] permissions, Device device) {
|
|
90
|
+
JSObject ret = new JSObject();
|
|
91
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
92
|
+
ret.put("pushPermission", permissions[0].toString());
|
|
93
|
+
ret.put("locationPermission", permissions[1].toString());
|
|
94
|
+
call.resolve(ret);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
109
97
|
}
|
|
110
98
|
|
|
111
99
|
@PluginMethod
|
|
@@ -407,7 +395,7 @@ public class IndigitallCpPlugin extends Plugin implements IndigitallFirebaseInte
|
|
|
407
395
|
|
|
408
396
|
@PluginMethod
|
|
409
397
|
public void logIn(PluginCall call) {
|
|
410
|
-
String EXTERNAL_ID = "
|
|
398
|
+
String EXTERNAL_ID = "externalCode";
|
|
411
399
|
String externalId = call.getString(EXTERNAL_ID);
|
|
412
400
|
IndigitallCp.logIn(getContext(), externalId, new DeviceCallback(getContext()) {
|
|
413
401
|
@Override
|
|
@@ -3,6 +3,10 @@ package com.indigitall.capacitor;
|
|
|
3
3
|
import android.util.Log;
|
|
4
4
|
import android.webkit.WebView;
|
|
5
5
|
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
import androidx.annotation.Nullable;
|
|
8
|
+
|
|
9
|
+
import com.getcapacitor.JSArray;
|
|
6
10
|
import com.getcapacitor.JSObject;
|
|
7
11
|
import com.getcapacitor.Plugin;
|
|
8
12
|
import com.getcapacitor.PluginCall;
|
|
@@ -14,22 +18,29 @@ import com.indigitall.android.inapp.InAppIndigitall;
|
|
|
14
18
|
import com.indigitall.android.inapp.callbacks.GetInAppCallback;
|
|
15
19
|
import com.indigitall.android.inapp.callbacks.InAppCallback;
|
|
16
20
|
import com.indigitall.android.inapp.callbacks.InAppTopicCallback;
|
|
21
|
+
import com.indigitall.android.inapp.callbacks.InAppTopicListCallback;
|
|
17
22
|
import com.indigitall.android.inapp.callbacks.ShowInAppCallback;
|
|
18
23
|
import com.indigitall.android.inapp.models.InApp;
|
|
19
24
|
import com.indigitall.android.inapp.models.InAppErrorModel;
|
|
25
|
+
import com.indigitall.android.inapp.models.InAppTopic;
|
|
20
26
|
import com.indigitall.capacitor.implementations.InAppCp;
|
|
21
27
|
import com.indigitall.capacitor.utils.IndigitallInAppParse;
|
|
22
28
|
|
|
29
|
+
import org.json.JSONArray;
|
|
23
30
|
import org.json.JSONException;
|
|
24
31
|
import org.json.JSONObject;
|
|
25
32
|
|
|
33
|
+
import java.util.ArrayList;
|
|
34
|
+
|
|
26
35
|
@CapacitorPlugin(name = "InAppCp")
|
|
27
36
|
public class IndigitallInAppPlugin extends Plugin {
|
|
28
37
|
private final String IN_APP = "inApp";
|
|
29
38
|
private final String IN_APP_SCHEMA = "inAppSchemaCode";
|
|
30
39
|
private final String TOPICS = "topics";
|
|
31
40
|
private final String PARAMS = "params";
|
|
32
|
-
private final String PKN = "
|
|
41
|
+
private final String PKN = "packageNam";
|
|
42
|
+
|
|
43
|
+
private final String FORM = "form";
|
|
33
44
|
|
|
34
45
|
@PluginMethod
|
|
35
46
|
public void getPackageName(PluginCall call) {
|
|
@@ -62,51 +73,18 @@ public class IndigitallInAppPlugin extends Plugin {
|
|
|
62
73
|
public void inAppWasShown(PluginCall call) throws JSONException {
|
|
63
74
|
JSObject ret = new JSObject();
|
|
64
75
|
String MAP_INAPP_CODE = "inAppSchemaCode";
|
|
65
|
-
InAppCp.inAppWasShown(getContext(), call.getObject(PARAMS), new
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
@Override
|
|
78
|
-
public void onFail(ErrorModel errorModel) {
|
|
79
|
-
call.reject(IndigitallInAppParse.jsonFromErrorModel(errorModel).toString());
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@Override
|
|
86
|
-
public void didShowManyTimes(InApp inApp, InAppErrorModel inAppErrorModel) {
|
|
87
|
-
call.reject(IndigitallInAppParse.jsonFromInAppShowError(inApp, inAppErrorModel).toString());
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
@Override
|
|
91
|
-
public void didFound(InApp inApp) {
|
|
92
|
-
ret.put(IN_APP, IndigitallInAppParse.jsonFromInApp(inApp));
|
|
93
|
-
call.resolve(ret);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Override
|
|
97
|
-
public void didExpired(InApp inApp, InAppErrorModel inAppErrorModel) {
|
|
98
|
-
call.reject(IndigitallInAppParse.jsonFromInAppShowError(inApp, inAppErrorModel).toString());
|
|
99
|
-
}
|
|
76
|
+
InAppCp.inAppWasShown(getContext(), call.getObject(PARAMS), new InAppCallback(getContext()) {
|
|
77
|
+
@Override
|
|
78
|
+
public void onSuccess(InApp inApp) {
|
|
79
|
+
ret.put(IN_APP, IndigitallInAppParse.jsonFromInApp(inApp));
|
|
80
|
+
call.resolve(ret);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Override
|
|
84
|
+
public void onError(int i, String s, String s1) {
|
|
85
|
+
call.reject(s);
|
|
86
|
+
}
|
|
100
87
|
|
|
101
|
-
@Override
|
|
102
|
-
public void didDismissForever(InApp inApp, InAppErrorModel inAppErrorModel) {
|
|
103
|
-
call.reject(IndigitallInAppParse.jsonFromInAppShowError(inApp, inAppErrorModel).toString());
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@Override
|
|
107
|
-
public void didClickOut(InApp inApp, InAppErrorModel inAppErrorModel) {
|
|
108
|
-
call.reject(IndigitallInAppParse.jsonFromInAppShowError(inApp, inAppErrorModel).toString());
|
|
109
|
-
}
|
|
110
88
|
});
|
|
111
89
|
}
|
|
112
90
|
|
|
@@ -140,7 +118,7 @@ public class IndigitallInAppPlugin extends Plugin {
|
|
|
140
118
|
}
|
|
141
119
|
}
|
|
142
120
|
|
|
143
|
-
|
|
121
|
+
|
|
144
122
|
@PluginMethod
|
|
145
123
|
public void addNewInAppToDismissForever(PluginCall call) {
|
|
146
124
|
try {
|
|
@@ -218,8 +196,88 @@ public class IndigitallInAppPlugin extends Plugin {
|
|
|
218
196
|
public void onSuccess(InApp inApp) {
|
|
219
197
|
//ret.put(ACTION, "onSuccess");
|
|
220
198
|
}
|
|
199
|
+
|
|
200
|
+
@Override
|
|
201
|
+
public void didFormError(InApp inApp, ArrayList<InAppErrorModel> arrayList) {
|
|
202
|
+
ret.put(ACTION, "didFormError");
|
|
203
|
+
call.resolve(ret);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@Override
|
|
207
|
+
public void didFormSubmit(InApp inApp) {
|
|
208
|
+
ret.put(ACTION, "didFormSubmit");
|
|
209
|
+
call.resolve(ret);
|
|
210
|
+
}
|
|
221
211
|
});
|
|
222
212
|
}
|
|
223
213
|
|
|
214
|
+
@PluginMethod
|
|
215
|
+
public void topicList(PluginCall call) throws JSONException {
|
|
216
|
+
JSObject ret = new JSObject();
|
|
217
|
+
InAppCp.topicsList(getContext(), new BaseCallback() {
|
|
218
|
+
@Override
|
|
219
|
+
public void onSuccess(JSONObject jsonObject) {
|
|
220
|
+
ret.put(TOPICS, jsonObject);
|
|
221
|
+
call.resolve(ret);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@Override
|
|
225
|
+
public void onFail(@NonNull ErrorModel errorModel) {
|
|
226
|
+
call.reject(IndigitallInAppParse.jsonFromErrorModel(errorModel).toString());
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@PluginMethod
|
|
233
|
+
public void topicsSubscribe(PluginCall call) throws JSONException {
|
|
234
|
+
JSObject ret = new JSObject();
|
|
235
|
+
JSArray array = call.getArray(TOPICS);
|
|
236
|
+
String[] topicsList = new String[array.length()];
|
|
237
|
+
for (int i = 0; i < array.length(); i++) {
|
|
238
|
+
topicsList[i] = array.getString(i);
|
|
239
|
+
}
|
|
240
|
+
InAppCp.topicsSubscribe(getContext(), topicsList, new InAppTopicCallback() {
|
|
241
|
+
@Override
|
|
242
|
+
public void onSuccess(@NonNull String s) {
|
|
243
|
+
ret.put(TOPICS, s);
|
|
244
|
+
call.resolve(ret);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@Override
|
|
248
|
+
public void onError(@NonNull InAppErrorModel inAppErrorModel) {
|
|
249
|
+
call.reject(IndigitallInAppParse.jsonFromErrorModel(inAppErrorModel).toString());
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@PluginMethod
|
|
255
|
+
public void topicsUnsubscribe(PluginCall call) throws JSONException {
|
|
256
|
+
JSObject ret = new JSObject();
|
|
257
|
+
JSArray array = call.getArray(TOPICS);
|
|
258
|
+
String[] topicsList = new String[array.length()];
|
|
259
|
+
for (int i = 0; i < array.length(); i++) {
|
|
260
|
+
topicsList[i] = array.getString(i);
|
|
261
|
+
}
|
|
262
|
+
InAppCp.topicsUnsubscribe(getContext(), topicsList, new InAppTopicCallback() {
|
|
263
|
+
@Override
|
|
264
|
+
public void onSuccess(@NonNull String s) {
|
|
265
|
+
ret.put(TOPICS, s);
|
|
266
|
+
call.resolve(ret);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@Override
|
|
270
|
+
public void onError(@NonNull InAppErrorModel inAppErrorModel) {
|
|
271
|
+
call.reject(IndigitallInAppParse.jsonFromErrorModel(inAppErrorModel).toString());
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
@PluginMethod
|
|
277
|
+
public void formSubmit(PluginCall call) throws JSONException {
|
|
278
|
+
JSONArray array = call.getArray(FORM);
|
|
279
|
+
InAppCp.formSubmit(getContext(), array.getJSONObject(0), array, call);
|
|
280
|
+
}
|
|
281
|
+
|
|
224
282
|
}
|
|
225
283
|
|
|
@@ -5,13 +5,13 @@ import android.content.Context;
|
|
|
5
5
|
import com.getcapacitor.JSArray;
|
|
6
6
|
import com.getcapacitor.JSObject;
|
|
7
7
|
import com.indigitall.android.Indigitall;
|
|
8
|
-
import com.indigitall.android.callbacks.DeviceCallback;
|
|
8
|
+
import com.indigitall.android.push.callbacks.DeviceCallback;
|
|
9
9
|
import com.indigitall.android.commons.models.Channel;
|
|
10
10
|
import com.indigitall.android.commons.models.ErrorModel;
|
|
11
11
|
import com.indigitall.android.customer.CustomerIndigitall;
|
|
12
12
|
import com.indigitall.android.customer.callbacks.CustomerCallback;
|
|
13
13
|
import com.indigitall.android.customer.callbacks.CustomerFieldCallback;
|
|
14
|
-
import com.indigitall.android.models.Device;
|
|
14
|
+
import com.indigitall.android.push.models.Device;
|
|
15
15
|
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
16
16
|
|
|
17
17
|
import org.json.JSONArray;
|
|
@@ -51,7 +51,7 @@ public class CustomerCp {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
public static void link(Context context, JSObject params, final CustomerCallback callback) throws JSONException{
|
|
54
|
-
String JSON_EXTERNAL_ID = "
|
|
54
|
+
String JSON_EXTERNAL_ID = "externalCode";
|
|
55
55
|
String JSON_CHANNEL = "channel";
|
|
56
56
|
String externalId = null;
|
|
57
57
|
Channel channel = Channel.PUSH;
|
|
@@ -61,10 +61,10 @@ public class CustomerCp {
|
|
|
61
61
|
channel = IndigitallParse.parseChannel(Objects.requireNonNull(params.getString(JSON_CHANNEL)));
|
|
62
62
|
}
|
|
63
63
|
Channel finalChannel = channel;
|
|
64
|
-
Indigitall.logIn(context, externalId, new DeviceCallback(context) {
|
|
64
|
+
Indigitall.INSTANCE.logIn(context, externalId, new DeviceCallback(context) {
|
|
65
65
|
@Override
|
|
66
66
|
public void onSuccess(Device device) {
|
|
67
|
-
CustomerIndigitall.INSTANCE.
|
|
67
|
+
CustomerIndigitall.INSTANCE.link(context, finalChannel, callback);
|
|
68
68
|
}
|
|
69
69
|
@Override
|
|
70
70
|
public void onFail(ErrorModel error) { callback.onFail(error); }
|
|
@@ -78,10 +78,10 @@ public class CustomerCp {
|
|
|
78
78
|
channel = IndigitallParse.parseChannel(Objects.requireNonNull(params.getString(JSON_CHANNEL)));
|
|
79
79
|
}
|
|
80
80
|
Channel finalChannel = channel;
|
|
81
|
-
Indigitall.logOut(context, new DeviceCallback(context) {
|
|
81
|
+
Indigitall.INSTANCE.logOut(context, new DeviceCallback(context) {
|
|
82
82
|
@Override
|
|
83
83
|
public void onSuccess(Device device) {
|
|
84
|
-
CustomerIndigitall.INSTANCE.
|
|
84
|
+
CustomerIndigitall.INSTANCE.unlink(context, finalChannel, callback);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
@Override
|
|
@@ -9,11 +9,13 @@ import android.view.View;
|
|
|
9
9
|
import android.widget.ImageButton;
|
|
10
10
|
|
|
11
11
|
import com.getcapacitor.JSObject;
|
|
12
|
+
import com.getcapacitor.PluginCall;
|
|
12
13
|
import com.indigitall.android.commons.callbacks.BaseCallback;
|
|
13
14
|
import com.indigitall.android.commons.models.LogLevel;
|
|
14
15
|
import com.indigitall.android.inapp.InAppConfiguration;
|
|
15
16
|
import com.indigitall.android.inapp.InAppIndigitall;
|
|
16
17
|
import com.indigitall.android.inapp.Utils.EventUtils;
|
|
18
|
+
import com.indigitall.android.inapp.Utils.InAppFormUtils;
|
|
17
19
|
import com.indigitall.android.inapp.Utils.InAppUtils;
|
|
18
20
|
import com.indigitall.android.inapp.Utils.PopUpUtils;
|
|
19
21
|
import com.indigitall.android.inapp.Utils.ServiceUtils;
|
|
@@ -24,39 +26,43 @@ import com.indigitall.android.inapp.callbacks.InAppTopicCallback;
|
|
|
24
26
|
import com.indigitall.android.inapp.callbacks.ShowInAppCallback;
|
|
25
27
|
import com.indigitall.android.inapp.models.InApp;
|
|
26
28
|
import com.indigitall.android.inapp.models.InAppAction;
|
|
29
|
+
import com.indigitall.android.inapp.models.InAppErrorModel;
|
|
30
|
+
import com.indigitall.android.inapp.models.InAppForm;
|
|
31
|
+
import com.indigitall.capacitor.utils.IndigitallInAppParse;
|
|
27
32
|
|
|
33
|
+
import org.json.JSONArray;
|
|
28
34
|
import org.json.JSONException;
|
|
29
35
|
import org.json.JSONObject;
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
import java.util.ArrayList;
|
|
32
38
|
|
|
39
|
+
public class InAppCp {
|
|
40
|
+
private static final String IN_APP = "inApp";
|
|
33
41
|
public static void inAppGet(Context context, String inAppSchemaCode, InAppCallback callback) {
|
|
34
42
|
InAppIndigitall.inAppGet(context, inAppSchemaCode, callback);
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
public static void inAppWasShown(Context context, JSObject params,
|
|
45
|
+
public static void inAppWasShown(Context context, JSObject params, InAppCallback callback) throws JSONException {
|
|
38
46
|
String MAP_INAPP_CODE = "inAppSchemaCode";
|
|
39
47
|
String MAP_DOMAIN_INAPP = "domainInApp";
|
|
40
48
|
String MAP_APPKEY = "appKey";
|
|
41
49
|
|
|
42
50
|
String inAppCode = null;
|
|
43
51
|
String appKey = "";
|
|
44
|
-
String domainInApp = "https://device-api.indigitall.com/v2/
|
|
52
|
+
String domainInApp = "https://device-api.indigitall.com/v2/";
|
|
45
53
|
|
|
46
54
|
if (params.has(MAP_INAPP_CODE)) inAppCode = params.getString(MAP_INAPP_CODE);
|
|
47
55
|
if (params.has(MAP_APPKEY)) appKey = params.getString(MAP_APPKEY);
|
|
48
|
-
if (params.has(MAP_DOMAIN_INAPP)) domainInApp = params.getString(MAP_DOMAIN_INAPP)
|
|
56
|
+
if (params.has(MAP_DOMAIN_INAPP)) domainInApp = params.getString(MAP_DOMAIN_INAPP);
|
|
49
57
|
InAppConfiguration.Builder inAppConfiguration = new InAppConfiguration.Builder(appKey);
|
|
50
58
|
inAppConfiguration.setUrlInAppApi(domainInApp);
|
|
51
59
|
inAppConfiguration.setLogDebug(LogLevel.DEBUG);
|
|
52
60
|
InAppConfiguration config = inAppConfiguration.build();
|
|
53
|
-
|
|
54
|
-
config.updateConfiguration(context);
|
|
55
|
-
ShowInAppUtils.INSTANCE.inAppWasGot(context, inAppCode, callback);
|
|
61
|
+
InAppIndigitall.showCustomInApp(context, config, inAppCode, callback);
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
public static void addNewInAppClick(Context context, JSONObject json) throws JSONException {
|
|
59
|
-
InApp inApp = new InApp(json);
|
|
65
|
+
InApp inApp = new InApp(context, json);
|
|
60
66
|
if (inApp.getProperties() != null && inApp.getProperties().getAction() != null) {
|
|
61
67
|
Intent intent = inApp.getProperties().getAction().getIntent(context);
|
|
62
68
|
boolean isAppAction = inApp.getProperties().getAction().getType() == InAppAction.Type.APP;
|
|
@@ -65,7 +71,7 @@ public class InAppCp {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
public static void addNewInAppToDismissForever(Context context, JSONObject json) throws JSONException {
|
|
68
|
-
InApp inApp = new InApp(json);
|
|
74
|
+
InApp inApp = new InApp(context, json);
|
|
69
75
|
PopUpUtils.INSTANCE.addNewInAppToDismissForever(context, inApp);
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -81,11 +87,11 @@ public class InAppCp {
|
|
|
81
87
|
ImageButton imageCloseButton = null;
|
|
82
88
|
String imageCloseButtonName;
|
|
83
89
|
String appKey = "";
|
|
84
|
-
String domainInApp = "https://device-api.indigitall.com/v2
|
|
90
|
+
String domainInApp = "https://device-api.indigitall.com/v2";
|
|
85
91
|
|
|
86
92
|
if (params.has(MAP_INAPP_CODE)) inAppCode = params.getString(MAP_INAPP_CODE);
|
|
87
93
|
if (params.has(MAP_APPKEY)) appKey = params.getString(MAP_APPKEY);
|
|
88
|
-
if (params.has(MAP_DOMAIN_INAPP)) domainInApp = params.getString(MAP_DOMAIN_INAPP)
|
|
94
|
+
if (params.has(MAP_DOMAIN_INAPP)) domainInApp = params.getString(MAP_DOMAIN_INAPP);
|
|
89
95
|
if (params.has(MAP_INAPP_IMAGE_CLOSE_BUTTON)) {
|
|
90
96
|
imageCloseButtonName = params.getString(MAP_INAPP_IMAGE_CLOSE_BUTTON);
|
|
91
97
|
imageCloseButton = new ImageButton(context);
|
|
@@ -113,12 +119,12 @@ public class InAppCp {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
public static void eventPrintInAppRequest(Context context, JSONObject json) throws JSONException {
|
|
116
|
-
InApp inApp = new InApp(json);
|
|
122
|
+
InApp inApp = new InApp(context, json);
|
|
117
123
|
EventUtils.INSTANCE.sendEventPrint(context, inApp);
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
public static void eventClickInAppRequest(Context context, JSONObject json) throws JSONException {
|
|
121
|
-
InApp inApp = new InApp(json);
|
|
127
|
+
InApp inApp = new InApp(context, json);
|
|
122
128
|
EventUtils.INSTANCE.sendEventClick(context, inApp);
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -133,4 +139,37 @@ public class InAppCp {
|
|
|
133
139
|
public static void topicsUnsubscribe(Context context, String[] topics, InAppTopicCallback callback) {
|
|
134
140
|
InAppIndigitall.topicsUnsubscribe(context, topics, callback);
|
|
135
141
|
}
|
|
142
|
+
|
|
143
|
+
public static void formSubmit(Context context, JSONObject json, JSONArray params, PluginCall call) throws JSONException {
|
|
144
|
+
InAppForm inAppForm = null;
|
|
145
|
+
String jsonFormat = null;
|
|
146
|
+
String jsonCustomer = null;
|
|
147
|
+
InApp inApp = new InApp(context, json);
|
|
148
|
+
if(params.get(1) != null && params.get(1) instanceof String) {
|
|
149
|
+
inAppForm = new InAppForm(new JSONObject(params.getString(1)));
|
|
150
|
+
}
|
|
151
|
+
if(params.get(2) != null && params.get(2) instanceof String) {
|
|
152
|
+
jsonFormat = params.getString(2);
|
|
153
|
+
}
|
|
154
|
+
if(params.get(3) != null && params.get(3) instanceof String) {
|
|
155
|
+
jsonCustomer = params.getString(3);
|
|
156
|
+
}
|
|
157
|
+
if (inAppForm != null && jsonFormat != null) {
|
|
158
|
+
ArrayList<InAppErrorModel> errorList = InAppFormUtils.INSTANCE.checkFieldsForm(inAppForm, new JSONObject(jsonFormat));
|
|
159
|
+
if (errorList.isEmpty()) {
|
|
160
|
+
EventUtils.INSTANCE.sendEventForm(context, inApp, new JSONObject(jsonFormat));
|
|
161
|
+
JSObject ret = new JSObject();
|
|
162
|
+
ret.put(IN_APP, IndigitallInAppParse.jsonFromInApp(inApp));
|
|
163
|
+
call.resolve(ret);
|
|
164
|
+
} else {
|
|
165
|
+
call.reject(String.valueOf(errorList));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (jsonCustomer != null) {
|
|
169
|
+
JSONObject myjson = new JSONObject(jsonCustomer);
|
|
170
|
+
if (myjson.length() > 0) {
|
|
171
|
+
EventUtils.INSTANCE.sendEventFormToCustomer(context, myjson);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
136
175
|
}
|