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
|
@@ -1,27 +1,69 @@
|
|
|
1
1
|
package com.indigitall.capacitor.implementations;
|
|
2
2
|
|
|
3
|
+
import android.Manifest;
|
|
4
|
+
import android.app.Activity;
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
import android.content.Intent;
|
|
7
|
+
import android.content.pm.PackageManager;
|
|
8
|
+
import android.os.Build;
|
|
5
9
|
import android.os.Bundle;
|
|
6
10
|
|
|
11
|
+
import androidx.core.app.ActivityCompat;
|
|
12
|
+
import androidx.core.content.ContextCompat;
|
|
13
|
+
|
|
14
|
+
import com.getcapacitor.JSObject;
|
|
7
15
|
import com.getcapacitor.PluginCall;
|
|
8
|
-
import com.indigitall.android.
|
|
16
|
+
import com.indigitall.android.commons.Constants;
|
|
17
|
+
import com.indigitall.android.push.Configuration;
|
|
9
18
|
import com.indigitall.android.Indigitall;
|
|
10
|
-
import com.indigitall.android.
|
|
11
|
-
import com.indigitall.android.
|
|
12
|
-
import com.indigitall.android.callbacks.
|
|
13
|
-
import com.indigitall.android.callbacks.
|
|
14
|
-
import com.indigitall.android.callbacks.
|
|
15
|
-
import com.indigitall.android.
|
|
16
|
-
import com.indigitall.android.
|
|
19
|
+
import com.indigitall.android.push.api.Client;
|
|
20
|
+
import com.indigitall.android.push.api.requests.DeviceRequest;
|
|
21
|
+
import com.indigitall.android.push.callbacks.DeviceCallback;
|
|
22
|
+
import com.indigitall.android.push.callbacks.EventCallback;
|
|
23
|
+
import com.indigitall.android.push.callbacks.InitCallBack;
|
|
24
|
+
import com.indigitall.android.push.callbacks.PushTokenCallback;
|
|
25
|
+
import com.indigitall.android.push.callbacks.TopicsCallback;
|
|
26
|
+
import com.indigitall.android.push.models.DeviceStatus;
|
|
27
|
+
import com.indigitall.android.push.models.Push;
|
|
28
|
+
import com.indigitall.android.push.utils.PushPreferenceUtils;
|
|
29
|
+
import com.indigitall.android.push.utils.ServiceUtils;
|
|
30
|
+
import com.indigitall.capacitor.IndigitallCpPlugin;
|
|
17
31
|
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
18
32
|
|
|
19
33
|
import org.json.JSONException;
|
|
20
34
|
import org.json.JSONObject;
|
|
21
35
|
|
|
36
|
+
import java.util.ArrayList;
|
|
37
|
+
|
|
22
38
|
public class IndigitallCp {
|
|
23
39
|
|
|
24
|
-
public static void
|
|
40
|
+
public static void requestPushPermission(Context context) {
|
|
41
|
+
if (Build.VERSION.SDK_INT >= 33) {
|
|
42
|
+
String permission = "android.permission.POST_NOTIFICATIONS";
|
|
43
|
+
int code = Constants.REQUEST_PUSH_PERMISSION_CODE;
|
|
44
|
+
ArrayList<String> permissions = new ArrayList<>();
|
|
45
|
+
permissions.add(permission);
|
|
46
|
+
ActivityCompat.requestPermissions((Activity) context, permissions.toArray(new String[permissions.size()]), code);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public static void getPushPermissionStatus(Context context, PluginCall call) {
|
|
51
|
+
String permission = "android.permission.POST_NOTIFICATIONS";
|
|
52
|
+
try {
|
|
53
|
+
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
|
|
54
|
+
JSObject ret = new JSObject();
|
|
55
|
+
ret.put("STATUS", "denied");
|
|
56
|
+
call.resolve(ret);
|
|
57
|
+
} else {
|
|
58
|
+
JSObject ret = new JSObject();
|
|
59
|
+
ret.put("STATUS", "granted");
|
|
60
|
+
call.resolve(ret);
|
|
61
|
+
}
|
|
62
|
+
} catch (Exception ex) {
|
|
63
|
+
call.reject(ex.getLocalizedMessage());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
public static void initialize(Context context, Activity activity, JSONObject params, InitCallBack callback) {
|
|
25
67
|
final String JSON_APP_KEY = "appKey";
|
|
26
68
|
final String JSON_SENDER_ID = "senderId";
|
|
27
69
|
final String JSON_REQUEST_LOCATION = "requestLocation";
|
|
@@ -29,17 +71,19 @@ public class IndigitallCp {
|
|
|
29
71
|
final String JSON_PRODUCT_VERSION = "productVersion";
|
|
30
72
|
final String JSON_WIFI_FILTER = "wifiFilterEnabled";
|
|
31
73
|
final String JSON_URL_DEVICE_API = "urlDeviceApi";
|
|
32
|
-
final String JSON_URL_INAPP_API = "urlInAppApi";
|
|
33
74
|
final String JSON_URL_INBOX_API = "urlInboxApi";
|
|
75
|
+
final String JSON_SET_ALWAYS_LAUNCH_ON_INIT = "alwaysLaunchOnInit";
|
|
76
|
+
final String JSON_SET_AUTO_REQUEST_PUSH_PERMISSION = "autoRequestPushPermission";
|
|
34
77
|
|
|
35
78
|
String appKey = null,
|
|
36
79
|
senderId = null,
|
|
37
80
|
productName = null,
|
|
38
81
|
productVersion = null,
|
|
39
82
|
urlDeviceApi = "https://device-api.indigitall.com/v1",
|
|
40
|
-
urlInAppApi = "https://inapp-api.indigitall.com/v1",
|
|
41
83
|
urlInboxApi = "https://inbox-api.indigitall.com/v1";
|
|
42
84
|
boolean requestLocation = false,
|
|
85
|
+
alwaysLaunchOnInit = false,
|
|
86
|
+
autoRequestPushPermission = true,
|
|
43
87
|
wifiFilterEnabled = false;
|
|
44
88
|
try {
|
|
45
89
|
if (params.length() > 0) {
|
|
@@ -50,50 +94,67 @@ public class IndigitallCp {
|
|
|
50
94
|
if (params.has(JSON_PRODUCT_VERSION)) productVersion = params.getString(JSON_PRODUCT_VERSION);
|
|
51
95
|
if (params.has(JSON_WIFI_FILTER)) wifiFilterEnabled = params.getBoolean(JSON_WIFI_FILTER);
|
|
52
96
|
if (params.has(JSON_URL_DEVICE_API)) urlDeviceApi = params.getString(JSON_URL_DEVICE_API);
|
|
53
|
-
if (params.has(JSON_URL_INAPP_API)) urlInAppApi = params.getString(JSON_URL_INAPP_API);
|
|
54
97
|
if (params.has(JSON_URL_INBOX_API)) urlInboxApi = params.getString(JSON_URL_INBOX_API);
|
|
98
|
+
if (params.has(JSON_SET_ALWAYS_LAUNCH_ON_INIT)) alwaysLaunchOnInit = params.getBoolean(JSON_SET_ALWAYS_LAUNCH_ON_INIT);
|
|
99
|
+
if (params.has(JSON_SET_AUTO_REQUEST_PUSH_PERMISSION)) autoRequestPushPermission = params.getBoolean(JSON_SET_AUTO_REQUEST_PUSH_PERMISSION);
|
|
55
100
|
}
|
|
56
101
|
} catch(JSONException ex) {
|
|
57
102
|
ex.printStackTrace();
|
|
58
103
|
}
|
|
59
104
|
|
|
105
|
+
ArrayList<String> permissions = new ArrayList<>();
|
|
106
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
107
|
+
if (autoRequestPushPermission && Build.VERSION.SDK_INT >= 33) {
|
|
108
|
+
if (activity.checkSelfPermission("android.permission.POST_NOTIFICATIONS") !=
|
|
109
|
+
PackageManager.PERMISSION_GRANTED ){
|
|
110
|
+
permissions.add("android.permission.POST_NOTIFICATIONS");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (requestLocation && activity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
|
|
114
|
+
PackageManager.PERMISSION_GRANTED ){
|
|
115
|
+
permissions.add(Manifest.permission.ACCESS_FINE_LOCATION);
|
|
116
|
+
}
|
|
117
|
+
if (permissions.size() > 0) ActivityCompat.requestPermissions((Activity) context, permissions.toArray(new String[permissions.size()]), Constants.REQUEST_PERMISSION_CODE);
|
|
118
|
+
}
|
|
60
119
|
|
|
61
120
|
if (appKey != null && senderId != null) {
|
|
62
121
|
Configuration config = new Configuration.Builder(appKey, senderId)
|
|
63
|
-
.setDefaultActivity(
|
|
122
|
+
.setDefaultActivity(activity.getClass().getName())
|
|
64
123
|
.setAutoRequestPermissionLocation(requestLocation)
|
|
65
124
|
.setProductName(productName)
|
|
66
125
|
.setProductVersion(productVersion)
|
|
67
126
|
.wifiFilterEnabled(wifiFilterEnabled)
|
|
68
127
|
.setUrlDeviceApi(urlDeviceApi)
|
|
69
128
|
.setUrlInboxApi(urlInboxApi)
|
|
129
|
+
.setAlwaysLaunchOnInit(alwaysLaunchOnInit)
|
|
130
|
+
.setAutoRequestPushPermission(autoRequestPushPermission)
|
|
70
131
|
.build();
|
|
71
|
-
Indigitall.init(context,config, callback);
|
|
132
|
+
Indigitall.INSTANCE.init(context,config, callback);
|
|
72
133
|
}
|
|
73
134
|
}
|
|
74
135
|
|
|
75
136
|
public static void deviceGet(Context context, DeviceCallback callback) {
|
|
76
|
-
Indigitall.deviceGet(context, callback);
|
|
137
|
+
Indigitall.INSTANCE.deviceGet(context, callback);
|
|
77
138
|
}
|
|
78
139
|
|
|
79
140
|
public static void deviceEnable(Context context, DeviceCallback callback) {
|
|
80
|
-
Indigitall.deviceEnable(context, callback);
|
|
141
|
+
Indigitall.INSTANCE.deviceEnable(context, callback);
|
|
81
142
|
}
|
|
82
143
|
|
|
83
144
|
public static void deviceDisable(Context context, DeviceCallback callback) {
|
|
84
|
-
Indigitall.deviceDisable(context, callback);
|
|
145
|
+
Indigitall.INSTANCE.deviceDisable(context, callback);
|
|
85
146
|
}
|
|
86
147
|
|
|
87
148
|
public static void topicsList(Context context, TopicsCallback callback) {
|
|
88
|
-
Indigitall.topicsList(context, callback);
|
|
149
|
+
Indigitall.INSTANCE.topicsList(context, callback);
|
|
89
150
|
}
|
|
90
151
|
|
|
91
152
|
public static void topicsSubscribe(Context context, String[] topics, TopicsCallback callback) {
|
|
92
|
-
Indigitall.topicsSubscribe(context, topics, callback);
|
|
153
|
+
Indigitall.INSTANCE.topicsSubscribe(context, topics, callback);
|
|
93
154
|
}
|
|
94
155
|
|
|
95
156
|
public static void topicsUnsubscribe(Context context, String[] topics, TopicsCallback callback) {
|
|
96
|
-
Indigitall.topicsUnsubscribe(context, topics, callback);
|
|
157
|
+
Indigitall.INSTANCE.topicsUnsubscribe(context, topics, callback);
|
|
97
158
|
}
|
|
98
159
|
|
|
99
160
|
public static void sendCustomEvent(Context context, JSONObject json, EventCallback callback) throws JSONException {
|
|
@@ -103,7 +164,7 @@ public class IndigitallCp {
|
|
|
103
164
|
JSONObject eventCustomData = null;
|
|
104
165
|
if (json.has(JSON_EVENT)) eventCustom = json.getString(JSON_EVENT);
|
|
105
166
|
if (json.has(JSON_EVENT_DATA)) eventCustomData = new JSONObject(json.getString(JSON_EVENT_DATA));
|
|
106
|
-
Indigitall.sendCustomEvent(context, eventCustom, eventCustomData, callback);
|
|
167
|
+
Indigitall.INSTANCE.sendCustomEvent(context, eventCustom, eventCustomData, callback);
|
|
107
168
|
}
|
|
108
169
|
|
|
109
170
|
public static JSONObject getPush(Context context, Intent intent) throws JSONException {
|
|
@@ -144,10 +205,14 @@ public class IndigitallCp {
|
|
|
144
205
|
}
|
|
145
206
|
|
|
146
207
|
public static void logIn(Context context, String externalId, DeviceCallback callback) {
|
|
147
|
-
Indigitall.logIn(context, externalId, callback);
|
|
208
|
+
Indigitall.INSTANCE.logIn(context, externalId, callback);
|
|
148
209
|
}
|
|
149
210
|
|
|
150
211
|
public static void logOut(Context context, DeviceCallback callback) {
|
|
151
|
-
Indigitall.logOut(context, callback);
|
|
212
|
+
Indigitall.INSTANCE.logOut(context, callback);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public static void onRequestPermissionsResult(Context context, int requestCode, String[] permissions, int[] grantResults) {
|
|
216
|
+
Indigitall.INSTANCE.onRequestPermissionsResult(context, requestCode, permissions, grantResults);
|
|
152
217
|
}
|
|
153
218
|
}
|
package/android/src/main/java/com/indigitall/capacitor/models/CpIndigitallHiddenActivity.java
CHANGED
|
@@ -8,8 +8,8 @@ import android.util.Log;
|
|
|
8
8
|
|
|
9
9
|
import androidx.annotation.Nullable;
|
|
10
10
|
|
|
11
|
-
import com.indigitall.android.HiddenActivity;
|
|
12
|
-
import com.indigitall.android.models.Push;
|
|
11
|
+
import com.indigitall.android.push.HiddenActivity;
|
|
12
|
+
import com.indigitall.android.push.models.Push;
|
|
13
13
|
import com.indigitall.capacitor.IndigitallCpPlugin;
|
|
14
14
|
import com.indigitall.capacitor.utils.CpPreferenceUtils;
|
|
15
15
|
|
|
@@ -48,4 +48,4 @@ public class CpIndigitallHiddenActivity extends HiddenActivity {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
|
@@ -3,9 +3,12 @@ package com.indigitall.capacitor.models;
|
|
|
3
3
|
import android.app.PendingIntent;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
6
8
|
import com.indigitall.android.commons.models.CorePushAction;
|
|
7
|
-
import com.indigitall.android.models.Push;
|
|
8
|
-
import com.indigitall.android.models.
|
|
9
|
+
import com.indigitall.android.push.models.Push;
|
|
10
|
+
import com.indigitall.android.push.models.PushAction;
|
|
11
|
+
import com.indigitall.android.push.models.PushNotification;
|
|
9
12
|
import com.indigitall.capacitor.utils.CpIndigitallUtils;
|
|
10
13
|
|
|
11
14
|
public class CpPushNotification extends PushNotification {
|
|
@@ -22,9 +25,11 @@ public class CpPushNotification extends PushNotification {
|
|
|
22
25
|
super.showNotification(context);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
@Nullable
|
|
29
|
+
@Override
|
|
30
|
+
public PendingIntent getIntent(@Nullable PushAction pushAction, int clickedButton) {
|
|
31
|
+
return CpIndigitallUtils.getIntent(context, push, pushAction, clickedButton);
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
|
|
30
|
-
}
|
|
35
|
+
}
|
|
@@ -5,9 +5,9 @@ import android.util.Log;
|
|
|
5
5
|
|
|
6
6
|
import com.getcapacitor.PluginCall;
|
|
7
7
|
import com.google.firebase.messaging.RemoteMessage;
|
|
8
|
-
import com.indigitall.android.models.Push;
|
|
9
|
-
import com.indigitall.android.services.FirebaseMessagingService;
|
|
10
|
-
import com.indigitall.android.utils.FirebaseUtils;
|
|
8
|
+
import com.indigitall.android.push.models.Push;
|
|
9
|
+
import com.indigitall.android.push.services.FirebaseMessagingService;
|
|
10
|
+
import com.indigitall.android.push.utils.FirebaseUtils;
|
|
11
11
|
import com.indigitall.capacitor.IndigitallCpPlugin;
|
|
12
12
|
import com.indigitall.capacitor.implementations.IndigitallCp;
|
|
13
13
|
import com.indigitall.capacitor.models.CpPushNotification;
|
|
@@ -8,10 +8,10 @@ import android.content.Intent;
|
|
|
8
8
|
import com.indigitall.android.commons.models.CorePush;
|
|
9
9
|
import com.indigitall.android.commons.models.CorePushAction;
|
|
10
10
|
import com.indigitall.android.commons.utils.IntentUtils;
|
|
11
|
-
import com.indigitall.android.models.Push;
|
|
12
|
-
import com.indigitall.android.models.PushAction;
|
|
13
|
-
import com.indigitall.android.services.StatisticService;
|
|
14
|
-
import com.indigitall.android.utils.PushPreferenceUtils;
|
|
11
|
+
import com.indigitall.android.push.models.Push;
|
|
12
|
+
import com.indigitall.android.push.models.PushAction;
|
|
13
|
+
import com.indigitall.android.push.services.StatisticService;
|
|
14
|
+
import com.indigitall.android.push.utils.PushPreferenceUtils;
|
|
15
15
|
import com.indigitall.capacitor.models.CpIndigitallHiddenActivity;
|
|
16
16
|
|
|
17
17
|
public class CpIndigitallUtils {
|
|
@@ -19,37 +19,41 @@ import org.json.JSONObject;
|
|
|
19
19
|
import java.util.ArrayList;
|
|
20
20
|
|
|
21
21
|
public class IndigitallInAppParse {
|
|
22
|
-
|
|
23
|
-
public static JSONObject jsonFromInApp(InApp inApp) {
|
|
24
|
-
JSONObject json = new JSONObject();
|
|
25
|
-
final String JSON_INAPP_ID = "inAppId";
|
|
26
|
-
final String JSON_LAST_VERSION_ID = "lastVersionId";
|
|
27
|
-
final String JSON_SHOW_ONCE = "showOnce";
|
|
28
|
-
final String JSON_CACHE_TTL = "cacheTtl";
|
|
29
|
-
final String JSON_CREATION_DATE = "creationDate";
|
|
30
|
-
final String JSON_EXPIRED_DATE = "expiredDate";
|
|
31
|
-
final String JSON_PROPERTIES = "properties";
|
|
32
|
-
final String JSON_SCHEMA = "schema";
|
|
33
|
-
final String JSON_VERSION = "version";
|
|
34
|
-
final String JSON_CUSTOM_DATA = "customData";
|
|
35
|
-
final String JSON_INAPP_SHOW = "inAppShow";
|
|
36
22
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
public static JSONObject jsonFromInApp(InApp inApp) {
|
|
24
|
+
JSONObject json = new JSONObject();
|
|
25
|
+
final String JSON_INAPP_ID = "inAppId";
|
|
26
|
+
final String JSON_LAST_VERSION_ID = "lastVersionId";
|
|
27
|
+
final String JSON_SHOW_ONCE = "showOnce";
|
|
28
|
+
final String JSON_CACHE_TTL = "cacheTtl";
|
|
29
|
+
final String JSON_CREATION_DATE = "creationDate";
|
|
30
|
+
final String JSON_EXPIRED_DATE = "expiredDate";
|
|
31
|
+
final String JSON_PROPERTIES = "properties";
|
|
32
|
+
final String JSON_SCHEMA = "schema";
|
|
33
|
+
final String JSON_VERSION = "version";
|
|
34
|
+
final String JSON_CUSTOM_DATA = "customData";
|
|
35
|
+
final String JSON_INAPP_SHOW = "inAppShow";
|
|
36
|
+
final String JSON_INAPP_FILTERS = "filters";
|
|
37
|
+
final String JSON_INAPP_NAME = "name";
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
json.put(JSON_INAPP_ID, inApp.getInAppId());
|
|
41
|
+
json.put(JSON_LAST_VERSION_ID, inApp.getLastVersionId());
|
|
42
|
+
json.put(JSON_SHOW_ONCE, inApp.isShowOnce());
|
|
43
|
+
if (inApp.getCacheTtl() != null) json.put(JSON_CACHE_TTL, inApp.getCacheTtl());
|
|
44
|
+
if (inApp.getCreationDate() != null) json.put(JSON_CREATION_DATE, inApp.getCreationDate());
|
|
45
|
+
if (inApp.getExpiredDate() != null) json.put(JSON_EXPIRED_DATE, inApp.getExpiredDate());
|
|
46
|
+
if (inApp.getProperties() != null) json.put(JSON_PROPERTIES, jsonFromProperties(inApp.getProperties()));
|
|
47
|
+
if (inApp.getSchema() != null) json.put(JSON_SCHEMA, jsonFromSchema(inApp.getSchema()));
|
|
48
|
+
json.put(JSON_VERSION, inApp.getVersion());
|
|
49
|
+
if (inApp.getCustomData() != null) json.put(JSON_CUSTOM_DATA, new JSONObject(inApp.getCustomData()));
|
|
50
|
+
if (inApp.getInAppShow() != null) json.put(JSON_INAPP_SHOW, jsonFromInAppShow(inApp.getInAppShow()));
|
|
51
|
+
if (inApp.getName() != null) json.put(JSON_INAPP_NAME, inApp.getName());
|
|
52
|
+
if (inApp.getFilters() != null) json.put(JSON_INAPP_FILTERS, inApp.getFilters().toJSON());
|
|
53
|
+
} catch (JSONException ex) {
|
|
54
|
+
ex.printStackTrace();
|
|
55
|
+
}
|
|
56
|
+
return json;
|
|
53
57
|
}
|
|
54
58
|
public static JSONObject jsonFromSchema(InAppSchema schema) {
|
|
55
59
|
JSONObject json = new JSONObject();
|
|
@@ -117,6 +121,7 @@ public class IndigitallInAppParse {
|
|
|
117
121
|
final String JSON_TYPE_CALL = "call";
|
|
118
122
|
final String JSON_TYPE_MARKET = "market";
|
|
119
123
|
final String JSON_TYPE_SHARE = "share";
|
|
124
|
+
final String JSON_TYPE_WEBVIEW = "webview";
|
|
120
125
|
|
|
121
126
|
JSONObject json = new JSONObject();
|
|
122
127
|
try {
|
|
@@ -128,6 +133,7 @@ public class IndigitallInAppParse {
|
|
|
128
133
|
if (action.getCall() != null) json.put(JSON_TYPE_CALL, action.getCall() );
|
|
129
134
|
if (action.getMarket() != null) json.put(JSON_TYPE_MARKET, action.getMarket() );
|
|
130
135
|
if (action.getShare() != null) json.put(JSON_TYPE_SHARE, action.getShare() );
|
|
136
|
+
if (action.getWebview() != null) json.put(JSON_TYPE_WEBVIEW, action.getWebview() );
|
|
131
137
|
|
|
132
138
|
} catch (JSONException ex) {
|
|
133
139
|
ex.printStackTrace();
|
|
@@ -159,6 +165,17 @@ public class IndigitallInAppParse {
|
|
|
159
165
|
return json;
|
|
160
166
|
}
|
|
161
167
|
|
|
168
|
+
public static JSONObject jsonFromErrorModel(InAppErrorModel error) {
|
|
169
|
+
JSONObject json = new JSONObject();
|
|
170
|
+
try {
|
|
171
|
+
json.put("errorCode", error.getErrorCode());
|
|
172
|
+
json.put("errorMessage", error.getErrorMessage());
|
|
173
|
+
} catch (JSONException e) {
|
|
174
|
+
e.printStackTrace();
|
|
175
|
+
}
|
|
176
|
+
return json;
|
|
177
|
+
}
|
|
178
|
+
|
|
162
179
|
public static String[] parseArrayList(JSONArray array) {
|
|
163
180
|
String[] topicsList = new String[array.length()];
|
|
164
181
|
try {
|
|
@@ -171,8 +188,8 @@ public class IndigitallInAppParse {
|
|
|
171
188
|
return topicsList;
|
|
172
189
|
}
|
|
173
190
|
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
|
|
192
|
+
|
|
176
193
|
|
|
177
194
|
|
|
178
195
|
}
|
|
@@ -17,11 +17,12 @@ import com.indigitall.android.inbox.models.InboxCounters;
|
|
|
17
17
|
import com.indigitall.android.inbox.models.InboxNotification;
|
|
18
18
|
import com.indigitall.android.inbox.models.InboxPush;
|
|
19
19
|
import com.indigitall.android.inbox.models.InboxPushButton;
|
|
20
|
-
import com.indigitall.android.models.Device;
|
|
21
|
-
import com.indigitall.android.models.ExternalApp;
|
|
22
|
-
import com.indigitall.android.models.Push;
|
|
23
|
-
import com.indigitall.android.models.PushButton;
|
|
24
|
-
import com.indigitall.android.models.Topic;
|
|
20
|
+
import com.indigitall.android.push.models.Device;
|
|
21
|
+
import com.indigitall.android.push.models.ExternalApp;
|
|
22
|
+
import com.indigitall.android.push.models.Push;
|
|
23
|
+
import com.indigitall.android.push.models.PushButton;
|
|
24
|
+
import com.indigitall.android.push.models.Topic;
|
|
25
|
+
import com.indigitall.android.commons.models.CorePushButton;
|
|
25
26
|
|
|
26
27
|
import org.json.JSONArray;
|
|
27
28
|
import org.json.JSONException;
|
|
@@ -95,7 +96,13 @@ public class IndigitallParse {
|
|
|
95
96
|
json.put(JSON_BODY, message.getBody());
|
|
96
97
|
json.put(JSON_IMAGE, message.getImage());
|
|
97
98
|
if (message.getAction() != null) json.put(JSON_ACTION, jsonFromAction(message.getAction()));
|
|
98
|
-
|
|
99
|
+
if (message.getButtons() != null) {
|
|
100
|
+
ArrayList<PushButton> buttons = new ArrayList<PushButton>();
|
|
101
|
+
for (int i = 0; i < message.getButtons().size(); i++) {
|
|
102
|
+
buttons.add(new PushButton(message.getButtons().get(i).toString()));
|
|
103
|
+
}
|
|
104
|
+
json.put(JSON_BUTTONS, jsonFromPushButtons(buttons));
|
|
105
|
+
}
|
|
99
106
|
json.put(JSON_DATA, message.getData());
|
|
100
107
|
json.put(JSON_SECURED_DATA, message.getSecuredData());
|
|
101
108
|
|
|
@@ -155,14 +162,14 @@ public class IndigitallParse {
|
|
|
155
162
|
return json;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
private static JSONArray jsonFromPushButtons(ArrayList<
|
|
165
|
+
private static JSONArray jsonFromPushButtons(ArrayList<PushButton> buttons) {
|
|
159
166
|
final String JSON_LABEL = "label";
|
|
160
167
|
final String JSON_ACTION = "action";
|
|
161
168
|
|
|
162
169
|
JSONArray array = new JSONArray();
|
|
163
170
|
if (buttons != null) {
|
|
164
171
|
try {
|
|
165
|
-
for (
|
|
172
|
+
for (PushButton button : buttons) {
|
|
166
173
|
JSONObject json = new JSONObject();
|
|
167
174
|
json.put(JSON_LABEL, button.getLabel());
|
|
168
175
|
if (button.getAction() != null) json.put(JSON_ACTION,jsonFromAction(button.getAction()));
|
|
@@ -449,80 +456,6 @@ public class IndigitallParse {
|
|
|
449
456
|
return json;
|
|
450
457
|
}
|
|
451
458
|
|
|
452
|
-
public static JSONObject jsonFromInApp(InApp inApp) {
|
|
453
|
-
final String INAPPID = "inAppId";
|
|
454
|
-
final String LAST_VERSION_ID = "lastVersionId";
|
|
455
|
-
final String SHOW_ONCE = "showOnce";
|
|
456
|
-
final String RENEWAL_TIME = "renewalTime";
|
|
457
|
-
final String CREATION_DATE = "creationDate";
|
|
458
|
-
final String EXPIRED_DATE = "expiredDate";
|
|
459
|
-
final String PROPERTIES = "properties";
|
|
460
|
-
final String SCHEMA = "schema";
|
|
461
|
-
|
|
462
|
-
JSONObject json = new JSONObject();
|
|
463
|
-
try {
|
|
464
|
-
json.put(INAPPID, inApp.getInAppId());
|
|
465
|
-
json.put(LAST_VERSION_ID, inApp.getLastVersionId());
|
|
466
|
-
json.put(SHOW_ONCE, inApp.isShowOnce());
|
|
467
|
-
json.put(CREATION_DATE, inApp.getCreationDate());
|
|
468
|
-
json.put(EXPIRED_DATE, inApp.getExpiredDate());
|
|
469
|
-
json.put(PROPERTIES, jsonFromInAppProperties(inApp.getProperties()));
|
|
470
|
-
json.put(SCHEMA, jsonFromInAppSchema(inApp.getSchema()));
|
|
471
|
-
} catch (JSONException ex) {
|
|
472
|
-
ex.printStackTrace();
|
|
473
|
-
}
|
|
474
|
-
return json;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
public static JSONObject jsonFromInAppProperties(InAppProperties properties) {
|
|
478
|
-
final String ACTION = "action";
|
|
479
|
-
final String CONTENT_URL = "contentUrl";
|
|
480
|
-
final String SHOWTIME = "showTime";
|
|
481
|
-
final String LAYOUT = "layout";
|
|
482
|
-
final String NUMBER_OF_SHOWS = "numberOfShows";
|
|
483
|
-
final String NUMBER_OF_CLIKS = "numberOfClicks";
|
|
484
|
-
final String DISMISS_FOREVER = "dismissForever";
|
|
485
|
-
|
|
486
|
-
JSONObject json = new JSONObject();
|
|
487
|
-
try {
|
|
488
|
-
json.put(ACTION, jsonFromAction(properties.getAction()));
|
|
489
|
-
json.put(CONTENT_URL, properties.getContentUrl());
|
|
490
|
-
json.put(SHOWTIME, properties.getShowTime());
|
|
491
|
-
json.put(LAYOUT, jsonFromInAppLayout(properties.getLayout()));
|
|
492
|
-
json.put(NUMBER_OF_SHOWS, properties.getNumberOfShows());
|
|
493
|
-
json.put(NUMBER_OF_CLIKS, properties.getNumberOfClicks());
|
|
494
|
-
json.put(DISMISS_FOREVER, properties.getDismissForever());
|
|
495
|
-
} catch (JSONException ex) {
|
|
496
|
-
ex.printStackTrace();
|
|
497
|
-
}
|
|
498
|
-
return json;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
public static JSONObject jsonFromInAppLayout(InAppLayout layout) {
|
|
502
|
-
final String BORDER_RADIUS = "borderRadius";
|
|
503
|
-
JSONObject json = new JSONObject();
|
|
504
|
-
try {
|
|
505
|
-
json.put(BORDER_RADIUS, layout.getBorderRadius());
|
|
506
|
-
} catch (JSONException ex) {
|
|
507
|
-
ex.printStackTrace();
|
|
508
|
-
}
|
|
509
|
-
return json;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
public static JSONObject jsonFromInAppSchema(InAppSchema schema) {
|
|
513
|
-
final String CODE = "code";
|
|
514
|
-
final String WIDTH = "width";
|
|
515
|
-
final String HEIGHT = "height";
|
|
516
|
-
JSONObject json = new JSONObject();
|
|
517
|
-
try {
|
|
518
|
-
json.put(CODE, schema.getCode());
|
|
519
|
-
json.put(WIDTH, schema.getWidth());
|
|
520
|
-
json.put(HEIGHT, schema.getHeight());
|
|
521
|
-
} catch (JSONException ex) {
|
|
522
|
-
ex.printStackTrace();
|
|
523
|
-
}
|
|
524
|
-
return json;
|
|
525
|
-
}
|
|
526
459
|
|
|
527
460
|
|
|
528
461
|
}
|
package/dist/docs.json
CHANGED
|
@@ -5,6 +5,26 @@
|
|
|
5
5
|
"docs": "",
|
|
6
6
|
"tags": [],
|
|
7
7
|
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "requestPushPermission",
|
|
10
|
+
"signature": "() => Promise<any>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<any>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "",
|
|
15
|
+
"complexTypes": [],
|
|
16
|
+
"slug": "requestpushpermission"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "getPushPermissionStatus",
|
|
20
|
+
"signature": "() => Promise<any>",
|
|
21
|
+
"parameters": [],
|
|
22
|
+
"returns": "Promise<any>",
|
|
23
|
+
"tags": [],
|
|
24
|
+
"docs": "",
|
|
25
|
+
"complexTypes": [],
|
|
26
|
+
"slug": "getpushpermissionstatus"
|
|
27
|
+
},
|
|
8
28
|
{
|
|
9
29
|
"name": "initialize",
|
|
10
30
|
"signature": "(params: { config: any; }) => Promise<any>",
|
|
@@ -229,12 +249,12 @@
|
|
|
229
249
|
},
|
|
230
250
|
{
|
|
231
251
|
"name": "logIn",
|
|
232
|
-
"signature": "(param: {
|
|
252
|
+
"signature": "(param: { externalCode: string; }) => Promise<any>",
|
|
233
253
|
"parameters": [
|
|
234
254
|
{
|
|
235
255
|
"name": "param",
|
|
236
256
|
"docs": "",
|
|
237
|
-
"type": "{
|
|
257
|
+
"type": "{ externalCode: string; }"
|
|
238
258
|
}
|
|
239
259
|
],
|
|
240
260
|
"returns": "Promise<any>",
|