indigitall-capacitor-plugin 2.0.1 → 2.0.3
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/README.md +80 -4
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/indigitall/capacitor/IndigitallCpPlugin.java +87 -2
- package/android/src/main/java/com/indigitall/capacitor/interfaces/IndigitallFirebaseInterface.java +2 -0
- package/android/src/main/java/com/indigitall/capacitor/models/CpIndigitallHiddenActivity.java +50 -0
- package/android/src/main/java/com/indigitall/capacitor/models/CpPushNotification.java +30 -0
- package/android/src/main/java/com/indigitall/capacitor/services/IndigitallFirebaseMessagingService.java +7 -1
- package/android/src/main/java/com/indigitall/capacitor/utils/CpIndigitallUtils.java +49 -0
- package/android/src/main/java/com/indigitall/capacitor/utils/CpPreferenceUtils.java +70 -0
- package/dist/docs.json +142 -3
- package/dist/esm/Push.js +11 -17
- package/dist/esm/Push.js.map +1 -1
- package/dist/esm/definitions/pushDefinitions.d.ts +9 -1
- package/dist/esm/definitions/pushDefinitions.js.map +1 -1
- package/dist/plugin.cjs.js +11 -17
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +11 -17
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/IndigitallCpPlugin.swift +76 -6
- package/ios/Plugin/handlers/IndigitallNotificationHandler.swift +4 -2
- package/ios/Plugin/interfaces/IndigitallCpPlugin.m +4 -1
- package/ios/Plugin/utils/CpINDefaults.h +23 -0
- package/ios/Plugin/utils/CpINDefaults.m +52 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,10 @@ npx cap sync
|
|
|
21
21
|
* [`topicsSubscribe(...)`](#topicssubscribe)
|
|
22
22
|
* [`topicsUnsubscribe(...)`](#topicsunsubscribe)
|
|
23
23
|
* [`sendCustomEvent(...)`](#sendcustomevent)
|
|
24
|
-
* [`getPush()`](#getpush)
|
|
24
|
+
* [`getPush(...)`](#getpush)
|
|
25
|
+
* [`onIndigitallGetPush(...)`](#onindigitallgetpush)
|
|
26
|
+
* [`clearViewUrl()`](#clearviewurl)
|
|
27
|
+
* [`setDefaultViewUrl(...)`](#setdefaultviewurl)
|
|
25
28
|
* [`onMessageReceived(...)`](#onmessagereceived)
|
|
26
29
|
* [`getToken()`](#gettoken)
|
|
27
30
|
* [`isIndigitallPushNotification(...)`](#isindigitallpushnotification)
|
|
@@ -137,13 +140,56 @@ sendCustomEvent(params: { customEvent: any; }) => Promise<void>
|
|
|
137
140
|
--------------------
|
|
138
141
|
|
|
139
142
|
|
|
140
|
-
### getPush()
|
|
143
|
+
### getPush(...)
|
|
141
144
|
|
|
142
145
|
```typescript
|
|
143
|
-
getPush() =>
|
|
146
|
+
getPush(onSuccess: OnPushSuccessType, onError?: OnErrorCallbackType | undefined) => OnPushSuccessType
|
|
144
147
|
```
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
| Param | Type |
|
|
150
|
+
| --------------- | ------------------------------------------------------------------- |
|
|
151
|
+
| **`onSuccess`** | <code><a href="#onpushsuccesstype">OnPushSuccessType</a></code> |
|
|
152
|
+
| **`onError`** | <code><a href="#onerrorcallbacktype">OnErrorCallbackType</a></code> |
|
|
153
|
+
|
|
154
|
+
**Returns:** <code><a href="#onpushsuccesstype">OnPushSuccessType</a></code>
|
|
155
|
+
|
|
156
|
+
--------------------
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### onIndigitallGetPush(...)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
onIndigitallGetPush(onSuccess: OnPushSuccessType, onError?: OnErrorCallbackType | undefined) => OnPushSuccessType
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Param | Type |
|
|
166
|
+
| --------------- | ------------------------------------------------------------------- |
|
|
167
|
+
| **`onSuccess`** | <code><a href="#onpushsuccesstype">OnPushSuccessType</a></code> |
|
|
168
|
+
| **`onError`** | <code><a href="#onerrorcallbacktype">OnErrorCallbackType</a></code> |
|
|
169
|
+
|
|
170
|
+
**Returns:** <code><a href="#onpushsuccesstype">OnPushSuccessType</a></code>
|
|
171
|
+
|
|
172
|
+
--------------------
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### clearViewUrl()
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
clearViewUrl() => void
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
--------------------
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
### setDefaultViewUrl(...)
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
setDefaultViewUrl(params: { defaultView: string; }) => void
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Param | Type |
|
|
191
|
+
| ------------ | ------------------------------------- |
|
|
192
|
+
| **`params`** | <code>{ defaultView: string; }</code> |
|
|
147
193
|
|
|
148
194
|
--------------------
|
|
149
195
|
|
|
@@ -232,6 +278,36 @@ An intrinsic object that provides functions to convert JavaScript values to and
|
|
|
232
278
|
### Type Aliases
|
|
233
279
|
|
|
234
280
|
|
|
281
|
+
#### OnPushSuccessType
|
|
282
|
+
|
|
283
|
+
<code>(push: <a href="#push">Push</a>): void</code>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
#### Push
|
|
287
|
+
|
|
288
|
+
<code>{ title: string; body: string; image: string; data: string; securedData: string; action: <a href="#pushaction">PushAction</a>; buttons: [PushButton]; }</code>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
#### PushAction
|
|
292
|
+
|
|
293
|
+
<code>{ url: string | null; app: string | null; market: string | null; share: string | null; call: string | null; noAction: string | null; }</code>
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
#### PushButton
|
|
297
|
+
|
|
298
|
+
<code>{ label: string; action: <a href="#pushaction">PushAction</a>; }</code>
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
#### OnErrorCallbackType
|
|
302
|
+
|
|
303
|
+
<code>(error: <a href="#errorcallback">ErrorCallback</a>): void</code>
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
#### ErrorCallback
|
|
307
|
+
|
|
308
|
+
<code>{ message: string; }</code>
|
|
309
|
+
|
|
310
|
+
|
|
235
311
|
#### OnMessageReceivedSuccessType
|
|
236
312
|
|
|
237
313
|
<code>(json: <a href="#json">JSON</a>): void</code>
|
package/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ dependencies {
|
|
|
55
55
|
testImplementation "junit:junit:$junitVersion"
|
|
56
56
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
-
implementation('com.indigitall:android:5.
|
|
58
|
+
implementation('com.indigitall:android:5.2.+'){
|
|
59
59
|
exclude group: "com.indigitall", module: "android-hms"
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</intent-filter>
|
|
24
24
|
</receiver>
|
|
25
25
|
<activity
|
|
26
|
-
android:name="
|
|
26
|
+
android:name=".models.CpIndigitallHiddenActivity"
|
|
27
27
|
android:label="@string/app_name_sdk"
|
|
28
28
|
android:screenOrientation="portrait"
|
|
29
29
|
android:configChanges="orientation|keyboardHidden"
|
|
@@ -2,8 +2,12 @@ package com.indigitall.capacitor;
|
|
|
2
2
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import android.content.Context;
|
|
5
|
+
import android.content.Intent;
|
|
5
6
|
import android.content.pm.PackageManager;
|
|
7
|
+
import android.net.Uri;
|
|
6
8
|
import android.os.Build;
|
|
9
|
+
import android.os.Handler;
|
|
10
|
+
import android.util.Log;
|
|
7
11
|
|
|
8
12
|
import androidx.annotation.NonNull;
|
|
9
13
|
|
|
@@ -22,10 +26,12 @@ import com.indigitall.android.callbacks.TopicsCallback;
|
|
|
22
26
|
import com.indigitall.android.commons.models.ErrorModel;
|
|
23
27
|
import com.indigitall.android.models.Device;
|
|
24
28
|
import com.indigitall.android.models.Permission;
|
|
29
|
+
import com.indigitall.android.models.Push;
|
|
25
30
|
import com.indigitall.android.models.PushErrorModel;
|
|
26
31
|
import com.indigitall.android.models.Topic;
|
|
27
32
|
import com.indigitall.android.utils.FirebaseUtils;
|
|
28
33
|
import com.indigitall.capacitor.interfaces.IndigitallFirebaseInterface;
|
|
34
|
+
import com.indigitall.capacitor.utils.CpPreferenceUtils;
|
|
29
35
|
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
30
36
|
import com.indigitall.capacitor.implementations.IndigitallCp;
|
|
31
37
|
|
|
@@ -41,9 +47,11 @@ public class IndigitallCpPlugin extends Plugin implements IndigitallFirebaseInte
|
|
|
41
47
|
private final String TOPICS = "topics";
|
|
42
48
|
private final String TOKEN = "token";
|
|
43
49
|
private final String NOTIFICATION = "notification";
|
|
50
|
+
private final String PUSH = "push";
|
|
44
51
|
|
|
45
52
|
public static PluginCall notificationCall;
|
|
46
53
|
public static IndigitallFirebaseInterface indigitallInterface;
|
|
54
|
+
public static PluginCall getPushCallback;
|
|
47
55
|
|
|
48
56
|
@PluginMethod
|
|
49
57
|
public void initialize(PluginCall call) {
|
|
@@ -228,10 +236,87 @@ public class IndigitallCpPlugin extends Plugin implements IndigitallFirebaseInte
|
|
|
228
236
|
});
|
|
229
237
|
}
|
|
230
238
|
|
|
231
|
-
@PluginMethod
|
|
239
|
+
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
|
|
240
|
+
public void setDefaultViewUrl(PluginCall call) {
|
|
241
|
+
try{
|
|
242
|
+
String defaultView = call.getString("defaultView");
|
|
243
|
+
CpPreferenceUtils.setPushUrl(getContext(), defaultView);
|
|
244
|
+
CpPreferenceUtils.setNativePushUrl(getContext(), "");
|
|
245
|
+
} catch (Exception ex) {
|
|
246
|
+
ex.printStackTrace();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
|
|
251
|
+
public void clearViewUrl() {
|
|
252
|
+
CpPreferenceUtils.setPushUrl(getContext(), "");
|
|
253
|
+
CpPreferenceUtils.setNativePushUrl(getContext(), "");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
|
|
257
|
+
public void onIndigitallGetPush(PluginCall call) throws JSONException {
|
|
258
|
+
onIndigitallGetPush(call, null);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@Override
|
|
262
|
+
public void onIndigitallGetPush(PluginCall call, JSONObject json) throws JSONException {
|
|
263
|
+
if (json != null) {
|
|
264
|
+
if (bridge != null) {
|
|
265
|
+
String url = CpPreferenceUtils.getPushUrl(getContext());
|
|
266
|
+
String urlNative = CpPreferenceUtils.getNativePushUrl(getContext());
|
|
267
|
+
if (urlNative != null && !urlNative.equals("")) {
|
|
268
|
+
bridge.getWebView().post(new Runnable() {
|
|
269
|
+
@Override
|
|
270
|
+
public void run() {
|
|
271
|
+
CpPreferenceUtils.setPushString(getContext(), new Push(getContext(), json).toString());
|
|
272
|
+
bridge.getWebView().loadUrl(urlNative);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
} else if (url != null && !url.equals("")) {
|
|
276
|
+
bridge.getWebView().post(new Runnable() {
|
|
277
|
+
@Override
|
|
278
|
+
public void run() {
|
|
279
|
+
String completeUrl = bridge.getLocalUrl()+"/"+url;
|
|
280
|
+
//if (!completeUrl.equals(bridge.getLocalUrl())) {
|
|
281
|
+
bridge.getWebView().loadUrl(completeUrl);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
//}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
getPushCallback = call;
|
|
289
|
+
indigitallInterface = this;
|
|
290
|
+
bridge.getWebView().post(new Runnable() {
|
|
291
|
+
@Override
|
|
292
|
+
public void run() {
|
|
293
|
+
String urlGetPushMethod = CpPreferenceUtils.getPushUrl(getContext());
|
|
294
|
+
if (urlGetPushMethod == null || urlGetPushMethod.equals("")) {
|
|
295
|
+
CpPreferenceUtils.setNativePushUrl(getContext(), bridge.getWebView().getUrl());
|
|
296
|
+
Log.d("IndigigallCpPlugin", "set url to: " + bridge.getWebView().getUrl());
|
|
297
|
+
}
|
|
298
|
+
JSObject ret = new JSObject();
|
|
299
|
+
if (CpPreferenceUtils.getPushString(getContext()) != null &&
|
|
300
|
+
!CpPreferenceUtils.getPushString(getContext()).equals("")) {
|
|
301
|
+
Push push = new Push(getContext(), CpPreferenceUtils.getPushString(getContext()));
|
|
302
|
+
try {
|
|
303
|
+
ret.put(PUSH, IndigitallParse.jsonFromPush(push));
|
|
304
|
+
} catch (JSONException e) {
|
|
305
|
+
e.printStackTrace();
|
|
306
|
+
}
|
|
307
|
+
getPushCallback.setKeepAlive(true);
|
|
308
|
+
getPushCallback.resolve(ret);
|
|
309
|
+
CpPreferenceUtils.setPushString(getContext(), "");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
call.setKeepAlive(true);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
|
|
232
318
|
public void getPush(PluginCall call) throws JSONException {
|
|
233
319
|
JSObject ret = new JSObject();
|
|
234
|
-
String PUSH = "push";
|
|
235
320
|
ret.put(PUSH, IndigitallCp.getPush(getContext(), getActivity().getIntent()));
|
|
236
321
|
call.resolve(ret);
|
|
237
322
|
}
|
package/android/src/main/java/com/indigitall/capacitor/interfaces/IndigitallFirebaseInterface.java
CHANGED
|
@@ -5,8 +5,10 @@ import android.content.Context;
|
|
|
5
5
|
import com.getcapacitor.JSObject;
|
|
6
6
|
import com.getcapacitor.PluginCall;
|
|
7
7
|
|
|
8
|
+
import org.json.JSONException;
|
|
8
9
|
import org.json.JSONObject;
|
|
9
10
|
|
|
10
11
|
public abstract interface IndigitallFirebaseInterface {
|
|
11
12
|
public abstract void onMessageReceived(JSONObject messageJson);
|
|
13
|
+
public abstract void onIndigitallGetPush(PluginCall call, JSONObject json) throws JSONException;
|
|
12
14
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package com.indigitall.capacitor.models;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.content.pm.PackageManager;
|
|
6
|
+
import android.os.Bundle;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
|
|
10
|
+
import com.indigitall.android.HiddenActivity;
|
|
11
|
+
import com.indigitall.android.models.Push;
|
|
12
|
+
import com.indigitall.capacitor.IndigitallCpPlugin;
|
|
13
|
+
import com.indigitall.capacitor.utils.CpPreferenceUtils;
|
|
14
|
+
|
|
15
|
+
import org.json.JSONObject;
|
|
16
|
+
|
|
17
|
+
public class CpIndigitallHiddenActivity extends HiddenActivity {
|
|
18
|
+
@Override
|
|
19
|
+
protected void onCreate(@Nullable Bundle bundle) {
|
|
20
|
+
super.onCreate(bundle);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Override
|
|
24
|
+
protected void onHandleIntentAction(Intent intentAction) {
|
|
25
|
+
try{
|
|
26
|
+
if (IndigitallCpPlugin.indigitallInterface != null && IndigitallCpPlugin.getPushCallback != null) {
|
|
27
|
+
if (intentAction.hasExtra(Push.EXTRA_PUSH)) {
|
|
28
|
+
JSONObject json = new JSONObject(intentAction.getStringExtra(Push.EXTRA_PUSH));
|
|
29
|
+
IndigitallCpPlugin.indigitallInterface.onIndigitallGetPush(null, json);
|
|
30
|
+
Context context = getApplicationContext();
|
|
31
|
+
PackageManager manager = context.getPackageManager();
|
|
32
|
+
|
|
33
|
+
Intent i = manager.getLaunchIntentForPackage(getPackageName());
|
|
34
|
+
if (i != null) {
|
|
35
|
+
i.addCategory(Intent.CATEGORY_LAUNCHER);
|
|
36
|
+
}
|
|
37
|
+
context.startActivity(i);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (intentAction.hasExtra(Push.EXTRA_PUSH)) {
|
|
41
|
+
CpPreferenceUtils.setPushString(getApplicationContext(), intentAction.getStringExtra(Push.EXTRA_PUSH));
|
|
42
|
+
}
|
|
43
|
+
super.onHandleIntentAction(intentAction);
|
|
44
|
+
}
|
|
45
|
+
} catch (Exception ex) {
|
|
46
|
+
ex.printStackTrace();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.indigitall.capacitor.models;
|
|
2
|
+
|
|
3
|
+
import android.app.PendingIntent;
|
|
4
|
+
import android.content.Context;
|
|
5
|
+
|
|
6
|
+
import com.indigitall.android.commons.models.CorePushAction;
|
|
7
|
+
import com.indigitall.android.models.Push;
|
|
8
|
+
import com.indigitall.android.models.PushNotification;
|
|
9
|
+
import com.indigitall.capacitor.utils.CpIndigitallUtils;
|
|
10
|
+
|
|
11
|
+
public class CpPushNotification extends PushNotification {
|
|
12
|
+
Push push;
|
|
13
|
+
Context context;
|
|
14
|
+
public CpPushNotification(Push push) {
|
|
15
|
+
super(push);
|
|
16
|
+
this.push = push;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public void showNotification(Context context) {
|
|
21
|
+
this.context = context;
|
|
22
|
+
super.showNotification(context);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public PendingIntent getIntent(CorePushAction action, int clickedButton) {
|
|
27
|
+
return CpIndigitallUtils.getIntent(context, push, action, clickedButton);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
package com.indigitall.capacitor.services;
|
|
2
2
|
|
|
3
|
+
import android.content.Context;
|
|
3
4
|
import android.util.Log;
|
|
4
5
|
|
|
5
6
|
import com.getcapacitor.PluginCall;
|
|
6
7
|
import com.google.firebase.messaging.RemoteMessage;
|
|
8
|
+
import com.indigitall.android.models.Push;
|
|
7
9
|
import com.indigitall.android.services.FirebaseMessagingService;
|
|
8
10
|
import com.indigitall.android.utils.FirebaseUtils;
|
|
9
11
|
import com.indigitall.capacitor.IndigitallCpPlugin;
|
|
10
12
|
import com.indigitall.capacitor.implementations.IndigitallCp;
|
|
13
|
+
import com.indigitall.capacitor.models.CpPushNotification;
|
|
11
14
|
|
|
12
15
|
import org.json.JSONObject;
|
|
13
16
|
import java.util.Map;
|
|
@@ -30,5 +33,8 @@ public class IndigitallFirebaseMessagingService extends FirebaseMessagingService
|
|
|
30
33
|
super.onNewToken(s);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
@Override
|
|
37
|
+
protected void showNotification(Context context, Push push) {
|
|
38
|
+
new CpPushNotification(push).showNotification(context);
|
|
39
|
+
}
|
|
34
40
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.indigitall.capacitor.utils;
|
|
2
|
+
|
|
3
|
+
import android.app.PendingIntent;
|
|
4
|
+
import android.app.TaskStackBuilder;
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.content.Intent;
|
|
7
|
+
|
|
8
|
+
import com.indigitall.android.commons.models.CorePush;
|
|
9
|
+
import com.indigitall.android.commons.models.CorePushAction;
|
|
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;
|
|
15
|
+
import com.indigitall.capacitor.models.CpIndigitallHiddenActivity;
|
|
16
|
+
|
|
17
|
+
public class CpIndigitallUtils {
|
|
18
|
+
public static PendingIntent getIntent(Context context, CorePush push, CorePushAction action, int clickedButton) {
|
|
19
|
+
try{
|
|
20
|
+
Intent intent = action.getIntent(context);
|
|
21
|
+
if (intent != null) {
|
|
22
|
+
if (action.getType() == PushAction.Type.APP) {
|
|
23
|
+
intent.putExtra(Push.EXTRA_PUSH, push.toString());
|
|
24
|
+
}
|
|
25
|
+
Intent indigitallIntent = new Intent(context, CpIndigitallHiddenActivity.class);
|
|
26
|
+
indigitallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
27
|
+
indigitallIntent.putExtra(StatisticService.EXTRA_APP_KEY, PushPreferenceUtils.getAppKey(context));
|
|
28
|
+
indigitallIntent.putExtra(StatisticService.EXTRA_PUSH_ID, push.getId());
|
|
29
|
+
indigitallIntent.putExtra(StatisticService.EXTRA_CLICKED_BUTTON, clickedButton);
|
|
30
|
+
indigitallIntent.putExtra(StatisticService.EXTRA_INTENT_ACTION, intent);
|
|
31
|
+
indigitallIntent.putExtra(Push.EXTRA_PUSH, push.toString());
|
|
32
|
+
if (action.getTopics() != null && action.getTopics().length>0){
|
|
33
|
+
indigitallIntent.putExtra(StatisticService.EXTRA_ACTION_TOPICS, action.topicsToString());
|
|
34
|
+
}
|
|
35
|
+
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
|
|
36
|
+
stackBuilder.addNextIntentWithParentStack(indigitallIntent);
|
|
37
|
+
if (action.isDestroy()){
|
|
38
|
+
return stackBuilder.getPendingIntent((push.getId() * 10) + clickedButton,
|
|
39
|
+
IntentUtils.getPendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT));
|
|
40
|
+
}else{
|
|
41
|
+
return PendingIntent.getActivity(context, 0, new Intent(), IntentUtils.getPendingIntentFlags(0));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}catch(Exception e){
|
|
45
|
+
e.printStackTrace();
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
package com.indigitall.capacitor.utils;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.SharedPreferences;
|
|
5
|
+
|
|
6
|
+
public class CpPreferenceUtils {
|
|
7
|
+
|
|
8
|
+
private static final String SHARED_PREFERENCES_NAME = "IndigitallCordovaPreferences";
|
|
9
|
+
private static final String SHARED_PREFERENCES_URL_KEY = SHARED_PREFERENCES_NAME + ".getPushKey";
|
|
10
|
+
private static final String SHARED_PREFERENCES_NATIVE_URL_KEY = SHARED_PREFERENCES_NAME + ".getNativePushKey";
|
|
11
|
+
private static final String SHARED_PREFERENCES_PUSH_STRING = SHARED_PREFERENCES_NAME + ".getPushString";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
private static boolean savePreferences(Context context, Object param, String key) {
|
|
15
|
+
SharedPreferences pref = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
|
16
|
+
SharedPreferences.Editor editor = null;
|
|
17
|
+
if (pref != null) editor = pref.edit();
|
|
18
|
+
if (editor != null) {
|
|
19
|
+
if (param instanceof String) {
|
|
20
|
+
return editor.putString (key,(String)param).commit();
|
|
21
|
+
} else if (param instanceof Boolean) {
|
|
22
|
+
return editor.putBoolean(key,(Boolean)param).commit();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static String getSharedPreferencesString(Context context, String key) {
|
|
30
|
+
if (context != null){
|
|
31
|
+
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
|
32
|
+
if (prefs != null) return prefs.getString(key, null);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static Boolean getSharedPreferencesBoolean(Context context, String key) {
|
|
38
|
+
if (context != null){
|
|
39
|
+
SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
|
40
|
+
if (prefs != null) return prefs.getBoolean(key, false);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static String getPushUrl(Context context) {
|
|
46
|
+
return getSharedPreferencesString(context, SHARED_PREFERENCES_URL_KEY);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public static void setPushUrl(Context context, String value) {
|
|
50
|
+
savePreferences(context, value, SHARED_PREFERENCES_URL_KEY);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static String getNativePushUrl(Context context) {
|
|
54
|
+
return getSharedPreferencesString(context, SHARED_PREFERENCES_NATIVE_URL_KEY);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static void setNativePushUrl(Context context, String value) {
|
|
58
|
+
savePreferences(context, value, SHARED_PREFERENCES_NATIVE_URL_KEY);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public static String getPushString(Context context) {
|
|
62
|
+
return getSharedPreferencesString(context, SHARED_PREFERENCES_PUSH_STRING);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static void setPushString(Context context, String value) {
|
|
66
|
+
savePreferences(context, value, SHARED_PREFERENCES_PUSH_STRING);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
package/dist/docs.json
CHANGED
|
@@ -111,13 +111,77 @@
|
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
"name": "getPush",
|
|
114
|
-
"signature": "() =>
|
|
114
|
+
"signature": "(onSuccess: OnPushSuccessType, onError?: OnErrorCallbackType | undefined) => OnPushSuccessType",
|
|
115
|
+
"parameters": [
|
|
116
|
+
{
|
|
117
|
+
"name": "onSuccess",
|
|
118
|
+
"docs": "",
|
|
119
|
+
"type": "OnPushSuccessType"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "onError",
|
|
123
|
+
"docs": "",
|
|
124
|
+
"type": "OnErrorCallbackType | undefined"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"returns": "OnPushSuccessType",
|
|
128
|
+
"tags": [],
|
|
129
|
+
"docs": "",
|
|
130
|
+
"complexTypes": [
|
|
131
|
+
"OnPushSuccessType",
|
|
132
|
+
"OnErrorCallbackType"
|
|
133
|
+
],
|
|
134
|
+
"slug": "getpush"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "onIndigitallGetPush",
|
|
138
|
+
"signature": "(onSuccess: OnPushSuccessType, onError?: OnErrorCallbackType | undefined) => OnPushSuccessType",
|
|
139
|
+
"parameters": [
|
|
140
|
+
{
|
|
141
|
+
"name": "onSuccess",
|
|
142
|
+
"docs": "",
|
|
143
|
+
"type": "OnPushSuccessType"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "onError",
|
|
147
|
+
"docs": "",
|
|
148
|
+
"type": "OnErrorCallbackType | undefined"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"returns": "OnPushSuccessType",
|
|
152
|
+
"tags": [],
|
|
153
|
+
"docs": "",
|
|
154
|
+
"complexTypes": [
|
|
155
|
+
"OnPushSuccessType",
|
|
156
|
+
"OnErrorCallbackType"
|
|
157
|
+
],
|
|
158
|
+
"slug": "onindigitallgetpush"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "clearViewUrl",
|
|
162
|
+
"signature": "() => void",
|
|
115
163
|
"parameters": [],
|
|
116
|
-
"returns": "
|
|
164
|
+
"returns": "void",
|
|
117
165
|
"tags": [],
|
|
118
166
|
"docs": "",
|
|
119
167
|
"complexTypes": [],
|
|
120
|
-
"slug": "
|
|
168
|
+
"slug": "clearviewurl"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "setDefaultViewUrl",
|
|
172
|
+
"signature": "(params: { defaultView: string; }) => void",
|
|
173
|
+
"parameters": [
|
|
174
|
+
{
|
|
175
|
+
"name": "params",
|
|
176
|
+
"docs": "",
|
|
177
|
+
"type": "{ defaultView: string; }"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"returns": "void",
|
|
181
|
+
"tags": [],
|
|
182
|
+
"docs": "",
|
|
183
|
+
"complexTypes": [],
|
|
184
|
+
"slug": "setdefaultviewurl"
|
|
121
185
|
},
|
|
122
186
|
{
|
|
123
187
|
"name": "onMessageReceived",
|
|
@@ -313,6 +377,81 @@
|
|
|
313
377
|
],
|
|
314
378
|
"enums": [],
|
|
315
379
|
"typeAliases": [
|
|
380
|
+
{
|
|
381
|
+
"name": "OnPushSuccessType",
|
|
382
|
+
"slug": "onpushsuccesstype",
|
|
383
|
+
"docs": "",
|
|
384
|
+
"types": [
|
|
385
|
+
{
|
|
386
|
+
"text": "(push: Push): void",
|
|
387
|
+
"complexTypes": [
|
|
388
|
+
"Push"
|
|
389
|
+
]
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"name": "Push",
|
|
395
|
+
"slug": "push",
|
|
396
|
+
"docs": "",
|
|
397
|
+
"types": [
|
|
398
|
+
{
|
|
399
|
+
"text": "{\n title: string;\n body: string;\n image: string;\n data: string;\n securedData: string;\n action: PushAction;\n buttons: [PushButton];\n }",
|
|
400
|
+
"complexTypes": [
|
|
401
|
+
"PushAction",
|
|
402
|
+
"PushButton"
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
]
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"name": "PushAction",
|
|
409
|
+
"slug": "pushaction",
|
|
410
|
+
"docs": "",
|
|
411
|
+
"types": [
|
|
412
|
+
{
|
|
413
|
+
"text": "{\n url: string | null;\n app: string | null;\n market: string | null;\n share: string | null;\n call: string | null;\n noAction: string | null;\n }",
|
|
414
|
+
"complexTypes": []
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"name": "PushButton",
|
|
420
|
+
"slug": "pushbutton",
|
|
421
|
+
"docs": "",
|
|
422
|
+
"types": [
|
|
423
|
+
{
|
|
424
|
+
"text": "{\n label: string;\n action: PushAction;\n }",
|
|
425
|
+
"complexTypes": [
|
|
426
|
+
"PushAction"
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
]
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"name": "OnErrorCallbackType",
|
|
433
|
+
"slug": "onerrorcallbacktype",
|
|
434
|
+
"docs": "",
|
|
435
|
+
"types": [
|
|
436
|
+
{
|
|
437
|
+
"text": "(error: ErrorCallback): void",
|
|
438
|
+
"complexTypes": [
|
|
439
|
+
"ErrorCallback"
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"name": "ErrorCallback",
|
|
446
|
+
"slug": "errorcallback",
|
|
447
|
+
"docs": "",
|
|
448
|
+
"types": [
|
|
449
|
+
{
|
|
450
|
+
"text": "{\n message: string;\n}",
|
|
451
|
+
"complexTypes": []
|
|
452
|
+
}
|
|
453
|
+
]
|
|
454
|
+
},
|
|
316
455
|
{
|
|
317
456
|
"name": "OnMessageReceivedSuccessType",
|
|
318
457
|
"slug": "onmessagereceivedsuccesstype",
|