indigitall-capacitor-plugin 0.0.1
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 +18 -0
- package/README.md +171 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +47 -0
- package/android/src/main/java/com/indigitall/capacitor/IndigitallCpPlugin.java +263 -0
- package/android/src/main/java/com/indigitall/capacitor/IndigitallCustomerPlugin.java +143 -0
- package/android/src/main/java/com/indigitall/capacitor/IndigitallInAppPlugin.java +159 -0
- package/android/src/main/java/com/indigitall/capacitor/IndigitallInboxPlugin.java +150 -0
- package/android/src/main/java/com/indigitall/capacitor/implementations/CustomerCp.java +91 -0
- package/android/src/main/java/com/indigitall/capacitor/implementations/InAppCp.java +74 -0
- package/android/src/main/java/com/indigitall/capacitor/implementations/InboxCp.java +118 -0
- package/android/src/main/java/com/indigitall/capacitor/implementations/IndigitallCp.java +130 -0
- package/android/src/main/java/com/indigitall/capacitor/utils/IndigitallParse.java +480 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +155 -0
- package/dist/esm/Customer.d.ts +4 -0
- package/dist/esm/Customer.js +61 -0
- package/dist/esm/Customer.js.map +1 -0
- package/dist/esm/InApp.d.ts +3 -0
- package/dist/esm/InApp.js +187 -0
- package/dist/esm/InApp.js.map +1 -0
- package/dist/esm/Inbox.d.ts +4 -0
- package/dist/esm/Inbox.js +61 -0
- package/dist/esm/Inbox.js.map +1 -0
- package/dist/esm/Push.d.ts +3 -0
- package/dist/esm/Push.js +110 -0
- package/dist/esm/Push.js.map +1 -0
- package/dist/esm/callbacks/callbacksType.d.ts +20 -0
- package/dist/esm/callbacks/callbacksType.js +2 -0
- package/dist/esm/callbacks/callbacksType.js.map +1 -0
- package/dist/esm/definitions/customerDefinitions.d.ts +34 -0
- package/dist/esm/definitions/customerDefinitions.js +2 -0
- package/dist/esm/definitions/customerDefinitions.js.map +1 -0
- package/dist/esm/definitions/inAppDefinitions.d.ts +35 -0
- package/dist/esm/definitions/inAppDefinitions.js +2 -0
- package/dist/esm/definitions/inAppDefinitions.js.map +1 -0
- package/dist/esm/definitions/inboxDefinitions.d.ts +30 -0
- package/dist/esm/definitions/inboxDefinitions.js +2 -0
- package/dist/esm/definitions/inboxDefinitions.js.map +1 -0
- package/dist/esm/definitions/pushDefinitions.d.ts +38 -0
- package/dist/esm/definitions/pushDefinitions.js +2 -0
- package/dist/esm/definitions/pushDefinitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/models/InCustomer.d.ts +16 -0
- package/dist/esm/models/InCustomer.js +8 -0
- package/dist/esm/models/InCustomer.js.map +1 -0
- package/dist/esm/models/InDevice.d.ts +31 -0
- package/dist/esm/models/InDevice.js +2 -0
- package/dist/esm/models/InDevice.js.map +1 -0
- package/dist/esm/models/InInApp.d.ts +31 -0
- package/dist/esm/models/InInApp.js +2 -0
- package/dist/esm/models/InInApp.js.map +1 -0
- package/dist/esm/models/InInbox.d.ts +31 -0
- package/dist/esm/models/InInbox.js +8 -0
- package/dist/esm/models/InInbox.js.map +1 -0
- package/dist/esm/models/InPush.d.ts +22 -0
- package/dist/esm/models/InPush.js +2 -0
- package/dist/esm/models/InPush.js.map +1 -0
- package/dist/esm/params/customerParams.d.ts +11 -0
- package/dist/esm/params/customerParams.js +3 -0
- package/dist/esm/params/customerParams.js.map +1 -0
- package/dist/esm/params/inAppParams.d.ts +17 -0
- package/dist/esm/params/inAppParams.js +3 -0
- package/dist/esm/params/inAppParams.js.map +1 -0
- package/dist/esm/params/inboxParams.d.ts +15 -0
- package/dist/esm/params/inboxParams.js +3 -0
- package/dist/esm/params/inboxParams.js.map +1 -0
- package/dist/esm/params/pushParams.d.ts +22 -0
- package/dist/esm/params/pushParams.js +2 -0
- package/dist/esm/params/pushParams.js.map +1 -0
- package/dist/plugin.cjs.js +434 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +437 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/IndigitallCpPlugin.swift +152 -0
- package/ios/Plugin/IndigitallCustomerPlugin.swift +76 -0
- package/ios/Plugin/IndigitallInAppPlugin.swift +54 -0
- package/ios/Plugin/IndigitallInboxPlugin.swift +81 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/handlers/IndigitallNotificationHandler.swift +38 -0
- package/ios/Plugin/implementations/CustomerCp.swift +56 -0
- package/ios/Plugin/implementations/InAppCp.swift +88 -0
- package/ios/Plugin/implementations/InboxCp.swift +78 -0
- package/ios/Plugin/implementations/IndigitallCp.swift +122 -0
- package/ios/Plugin/interfaces/IndigitallCpPlugin.h +10 -0
- package/ios/Plugin/interfaces/IndigitallCpPlugin.m +19 -0
- package/ios/Plugin/interfaces/IndigitallCustomerPlugin.h +10 -0
- package/ios/Plugin/interfaces/IndigitallCustomerPlugin.m +16 -0
- package/ios/Plugin/interfaces/IndigitallInAppPlugin.h +10 -0
- package/ios/Plugin/interfaces/IndigitallInAppPlugin.m +13 -0
- package/ios/Plugin/interfaces/IndigitallInboxPlugin.h +10 -0
- package/ios/Plugin/interfaces/IndigitallInboxPlugin.m +13 -0
- package/ios/Plugin/utils/IndigitallParse.h +27 -0
- package/ios/Plugin/utils/IndigitallParse.m +351 -0
- package/package.json +79 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'IndigitallCapacitorPlugin'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '10.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.dependency 'indigitall-ios'
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# indigitall-capacitor-plugin
|
|
2
|
+
|
|
3
|
+
Capacitor Indigitall Plugin
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install indigitall-capacitor-plugin
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
<docgen-index>
|
|
15
|
+
|
|
16
|
+
* [`initialize(...)`](#initialize)
|
|
17
|
+
* [`deviceGet()`](#deviceget)
|
|
18
|
+
* [`deviceEnable()`](#deviceenable)
|
|
19
|
+
* [`deviceDisable()`](#devicedisable)
|
|
20
|
+
* [`topicsList()`](#topicslist)
|
|
21
|
+
* [`topicsSubscribe(...)`](#topicssubscribe)
|
|
22
|
+
* [`topicsUnsubscribe(...)`](#topicsunsubscribe)
|
|
23
|
+
* [`sendCustomEvent(...)`](#sendcustomevent)
|
|
24
|
+
* [`getPush()`](#getpush)
|
|
25
|
+
* [`logIn(...)`](#login)
|
|
26
|
+
* [`logOut()`](#logout)
|
|
27
|
+
|
|
28
|
+
</docgen-index>
|
|
29
|
+
|
|
30
|
+
<docgen-api>
|
|
31
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
32
|
+
|
|
33
|
+
### initialize(...)
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
initialize(params: { config: any; }) => Promise<any>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Param | Type |
|
|
40
|
+
| ------------ | ----------------------------- |
|
|
41
|
+
| **`params`** | <code>{ config: any; }</code> |
|
|
42
|
+
|
|
43
|
+
**Returns:** <code>Promise<any></code>
|
|
44
|
+
|
|
45
|
+
--------------------
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### deviceGet()
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
deviceGet() => Promise<any>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Returns:** <code>Promise<any></code>
|
|
55
|
+
|
|
56
|
+
--------------------
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### deviceEnable()
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
deviceEnable() => Promise<any>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Returns:** <code>Promise<any></code>
|
|
66
|
+
|
|
67
|
+
--------------------
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### deviceDisable()
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
deviceDisable() => Promise<any>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Returns:** <code>Promise<any></code>
|
|
77
|
+
|
|
78
|
+
--------------------
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### topicsList()
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
topicsList() => Promise<any>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Returns:** <code>Promise<any></code>
|
|
88
|
+
|
|
89
|
+
--------------------
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### topicsSubscribe(...)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
topicsSubscribe(params: { topics: string[]; }) => Promise<any>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| Param | Type |
|
|
99
|
+
| ------------ | ---------------------------------- |
|
|
100
|
+
| **`params`** | <code>{ topics: string[]; }</code> |
|
|
101
|
+
|
|
102
|
+
**Returns:** <code>Promise<any></code>
|
|
103
|
+
|
|
104
|
+
--------------------
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### topicsUnsubscribe(...)
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
topicsUnsubscribe(params: { topics: string[]; }) => Promise<any>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| Param | Type |
|
|
114
|
+
| ------------ | ---------------------------------- |
|
|
115
|
+
| **`params`** | <code>{ topics: string[]; }</code> |
|
|
116
|
+
|
|
117
|
+
**Returns:** <code>Promise<any></code>
|
|
118
|
+
|
|
119
|
+
--------------------
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### sendCustomEvent(...)
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
sendCustomEvent(params: { customEvent: any; }) => Promise<void>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| Param | Type |
|
|
129
|
+
| ------------ | ---------------------------------- |
|
|
130
|
+
| **`params`** | <code>{ customEvent: any; }</code> |
|
|
131
|
+
|
|
132
|
+
--------------------
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### getPush()
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
getPush() => Promise<any>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Returns:** <code>Promise<any></code>
|
|
142
|
+
|
|
143
|
+
--------------------
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### logIn(...)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
logIn(param: { externalId: string; }) => Promise<any>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Param | Type |
|
|
153
|
+
| ----------- | ------------------------------------ |
|
|
154
|
+
| **`param`** | <code>{ externalId: string; }</code> |
|
|
155
|
+
|
|
156
|
+
**Returns:** <code>Promise<any></code>
|
|
157
|
+
|
|
158
|
+
--------------------
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### logOut()
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
logOut() => Promise<any>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Returns:** <code>Promise<any></code>
|
|
168
|
+
|
|
169
|
+
--------------------
|
|
170
|
+
|
|
171
|
+
</docgen-api>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
jcenter()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:4.2.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
|
|
22
|
+
defaultConfig {
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
|
|
25
|
+
versionCode 1
|
|
26
|
+
versionName "1.0"
|
|
27
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
28
|
+
}
|
|
29
|
+
buildTypes {
|
|
30
|
+
release {
|
|
31
|
+
minifyEnabled false
|
|
32
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
lintOptions {
|
|
36
|
+
abortOnError false
|
|
37
|
+
}
|
|
38
|
+
compileOptions {
|
|
39
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
40
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
repositories {
|
|
45
|
+
google()
|
|
46
|
+
mavenCentral()
|
|
47
|
+
jcenter()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
|
+
implementation project(':capacitor-android')
|
|
54
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
55
|
+
testImplementation "junit:junit:$junitVersion"
|
|
56
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
57
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
58
|
+
implementation('com.indigitall:android:4.18.+')
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.indigitall.capacitor">
|
|
3
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
|
+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
5
|
+
<uses-permission android:name="android.permission.VIBRATE" />
|
|
6
|
+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
7
|
+
|
|
8
|
+
<queries>
|
|
9
|
+
<intent>
|
|
10
|
+
<action android:name="android.intent.action.VIEW" />
|
|
11
|
+
<category android:name="android.intent.category.BROWSABLE" />
|
|
12
|
+
<data android:scheme="https" />
|
|
13
|
+
</intent>
|
|
14
|
+
</queries>
|
|
15
|
+
<application
|
|
16
|
+
android:allowBackup="true">
|
|
17
|
+
<service android:name="com.indigitall.android.services.StatisticService" />
|
|
18
|
+
<receiver android:name="com.indigitall.android.receivers.BootReceiver"
|
|
19
|
+
android:exported="false">
|
|
20
|
+
<intent-filter>
|
|
21
|
+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
|
22
|
+
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
|
23
|
+
</intent-filter>
|
|
24
|
+
</receiver>
|
|
25
|
+
<activity
|
|
26
|
+
android:name="com.indigitall.android.HiddenActivity"
|
|
27
|
+
android:label="@string/app_name_sdk"
|
|
28
|
+
android:screenOrientation="portrait"
|
|
29
|
+
android:configChanges="orientation|keyboardHidden"
|
|
30
|
+
android:taskAffinity=""
|
|
31
|
+
android:excludeFromRecents="true">
|
|
32
|
+
</activity>
|
|
33
|
+
<receiver android:name="com.indigitall.android.receivers.LocationReceiver"
|
|
34
|
+
android:exported="false">
|
|
35
|
+
<intent-filter>
|
|
36
|
+
<action android:name="LocationReceiver.Action.LOCATION_UPDATE" />
|
|
37
|
+
</intent-filter>
|
|
38
|
+
</receiver>
|
|
39
|
+
<service android:name="com.indigitall.android.services.FirebaseMessagingService"
|
|
40
|
+
android:exported="false">
|
|
41
|
+
<intent-filter>
|
|
42
|
+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
43
|
+
</intent-filter>
|
|
44
|
+
</service>
|
|
45
|
+
|
|
46
|
+
</application>
|
|
47
|
+
</manifest>
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
package com.indigitall.capacitor;
|
|
2
|
+
|
|
3
|
+
import android.Manifest;
|
|
4
|
+
import android.content.pm.PackageManager;
|
|
5
|
+
import android.os.Build;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
|
|
9
|
+
import com.getcapacitor.JSArray;
|
|
10
|
+
import com.getcapacitor.JSObject;
|
|
11
|
+
import com.getcapacitor.Plugin;
|
|
12
|
+
import com.getcapacitor.PluginCall;
|
|
13
|
+
import com.getcapacitor.PluginMethod;
|
|
14
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
15
|
+
import com.indigitall.android.callbacks.DeviceCallback;
|
|
16
|
+
import com.indigitall.android.callbacks.EventCallback;
|
|
17
|
+
import com.indigitall.android.callbacks.InitCallBack;
|
|
18
|
+
import com.indigitall.android.callbacks.TopicsCallback;
|
|
19
|
+
import com.indigitall.android.commons.models.Error;
|
|
20
|
+
import com.indigitall.android.models.Device;
|
|
21
|
+
import com.indigitall.android.models.Permission;
|
|
22
|
+
import com.indigitall.android.models.Topic;
|
|
23
|
+
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
24
|
+
import com.indigitall.capacitor.implementations.IndigitallCp;
|
|
25
|
+
|
|
26
|
+
import org.json.JSONException;
|
|
27
|
+
|
|
28
|
+
@CapacitorPlugin(name = "IndigitallCp")
|
|
29
|
+
public class IndigitallCpPlugin extends Plugin {
|
|
30
|
+
private final String DEVICE = "device";
|
|
31
|
+
private final String TOPICS = "topics";
|
|
32
|
+
|
|
33
|
+
@PluginMethod
|
|
34
|
+
public void initialize(PluginCall call) {
|
|
35
|
+
final String JSON_REQUEST_LOCATION = "requestLocation";
|
|
36
|
+
String CONFIG = "config";
|
|
37
|
+
JSObject obj = call.getObject(CONFIG);
|
|
38
|
+
boolean requestLocation = false;
|
|
39
|
+
if (obj != null) {
|
|
40
|
+
try {
|
|
41
|
+
if (obj.has(JSON_REQUEST_LOCATION)) {
|
|
42
|
+
requestLocation = obj.getBoolean(JSON_REQUEST_LOCATION);
|
|
43
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
44
|
+
if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
|
|
45
|
+
PackageManager.PERMISSION_GRANTED ){
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (NullPointerException | JSONException ex) {
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
// if (requestLocation){
|
|
54
|
+
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
55
|
+
// if (cordova.getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
|
|
56
|
+
// PackageManager.PERMISSION_GRANTED ){
|
|
57
|
+
// cordova.requestPermission(this, REQUEST_CODE_ASK_PERMISSIONS, Manifest.permission.ACCESS_FINE_LOCATION);
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
IndigitallCp.initialize(getContext(), getActivity().getClass().getName(), obj, new InitCallBack(getContext()) {
|
|
62
|
+
@Override
|
|
63
|
+
public void onErrorInitialized(Error error) {
|
|
64
|
+
call.reject(error.getErrorMessage());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Override
|
|
68
|
+
public void onErrorInitialized(String s) {
|
|
69
|
+
call.reject(s);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Override
|
|
73
|
+
public void onNewUserRegistered(Device device) {
|
|
74
|
+
JSObject ret = new JSObject();
|
|
75
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
76
|
+
call.resolve(ret);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Override
|
|
80
|
+
public void onIndigitallInitialized(Permission[] permissions, Device device) {
|
|
81
|
+
JSObject ret = new JSObject();
|
|
82
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
83
|
+
ret.put("pushPermission", permissions[0].toString());
|
|
84
|
+
ret.put("locationPermission", permissions[1].toString());
|
|
85
|
+
call.resolve(ret);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@PluginMethod
|
|
93
|
+
public void deviceGet(PluginCall call) {
|
|
94
|
+
IndigitallCp.deviceGet(getContext(), new DeviceCallback(getContext()) {
|
|
95
|
+
@Override
|
|
96
|
+
public void onSuccess(Device device) {
|
|
97
|
+
JSObject ret = new JSObject();
|
|
98
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
99
|
+
call.resolve(ret);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Override
|
|
103
|
+
public void onFail(Error error) {
|
|
104
|
+
call.reject(error.getErrorMessage());
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@PluginMethod
|
|
110
|
+
public void deviceEnable(PluginCall call) {
|
|
111
|
+
IndigitallCp.deviceEnable(getContext(), new DeviceCallback(getContext()) {
|
|
112
|
+
@Override
|
|
113
|
+
public void onSuccess(Device device) {
|
|
114
|
+
JSObject ret = new JSObject();
|
|
115
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
116
|
+
call.resolve(ret);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Override
|
|
120
|
+
public void onFail(Error error) {
|
|
121
|
+
call.reject(error.getErrorMessage());
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@PluginMethod
|
|
127
|
+
public void deviceDisable(PluginCall call) {
|
|
128
|
+
IndigitallCp.deviceDisable(getContext(), new DeviceCallback(getContext()) {
|
|
129
|
+
@Override
|
|
130
|
+
public void onSuccess(Device device) {
|
|
131
|
+
JSObject ret = new JSObject();
|
|
132
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
133
|
+
call.resolve(ret);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public void onFail(Error error) {
|
|
138
|
+
call.reject(error.getErrorMessage());
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@PluginMethod
|
|
144
|
+
public void topicsList(PluginCall call) {
|
|
145
|
+
IndigitallCp.topicsList(getContext(), new TopicsCallback() {
|
|
146
|
+
@Override
|
|
147
|
+
public void onSuccess(Topic[] topics) {
|
|
148
|
+
JSObject ret = new JSObject();
|
|
149
|
+
ret.put(TOPICS, IndigitallParse.jsonArrayFromTopicArray(topics));
|
|
150
|
+
call.resolve(ret);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Override
|
|
154
|
+
public void onFail(Error error) {
|
|
155
|
+
call.reject(error.getErrorMessage());
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@PluginMethod
|
|
161
|
+
public void topicsSubscribe(PluginCall call) throws JSONException {
|
|
162
|
+
JSArray array = call.getArray(TOPICS);
|
|
163
|
+
String[] topicsList = new String[array.length()];
|
|
164
|
+
for (int i = 0; i < array.length(); i++) {
|
|
165
|
+
topicsList[i] = array.getString(i);
|
|
166
|
+
}
|
|
167
|
+
IndigitallCp.topicsSubscribe(getContext(), topicsList, new TopicsCallback() {
|
|
168
|
+
@Override
|
|
169
|
+
public void onSuccess(Topic[] topics) {
|
|
170
|
+
JSObject ret = new JSObject();
|
|
171
|
+
ret.put(TOPICS, IndigitallParse.jsonArrayFromTopicArray(topics));
|
|
172
|
+
call.resolve(ret);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@Override
|
|
176
|
+
public void onFail(Error error) {
|
|
177
|
+
call.reject(error.getErrorMessage());
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@PluginMethod
|
|
183
|
+
public void topicsUnsubscribe(PluginCall call) throws JSONException {
|
|
184
|
+
JSArray array = call.getArray(TOPICS);
|
|
185
|
+
String[] topicsList = new String[array.length()];
|
|
186
|
+
for (int i = 0; i < array.length(); i++) {
|
|
187
|
+
topicsList[i] = array.getString(i);
|
|
188
|
+
}
|
|
189
|
+
IndigitallCp.topicsUnsubscribe(getContext(), topicsList, new TopicsCallback() {
|
|
190
|
+
@Override
|
|
191
|
+
public void onSuccess(Topic[] topics) {
|
|
192
|
+
JSObject ret = new JSObject();
|
|
193
|
+
ret.put(TOPICS, IndigitallParse.jsonArrayFromTopicArray(topics));
|
|
194
|
+
call.resolve(ret);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@Override
|
|
198
|
+
public void onFail(Error error) {
|
|
199
|
+
call.reject(error.getErrorMessage());
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@PluginMethod
|
|
205
|
+
public void sendCustomEvent(PluginCall call) throws JSONException {
|
|
206
|
+
String CUSTOM_EVENT = "customEvent";
|
|
207
|
+
IndigitallCp.sendCustomEvent(getContext(), call.getObject(CUSTOM_EVENT), new EventCallback(getContext()) {
|
|
208
|
+
@Override
|
|
209
|
+
public void onSuccess() {
|
|
210
|
+
call.resolve();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@Override
|
|
214
|
+
public void onError(@NonNull Error error) {
|
|
215
|
+
call.reject(error.getErrorMessage());
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@PluginMethod
|
|
221
|
+
public void getPush(PluginCall call) throws JSONException {
|
|
222
|
+
JSObject ret = new JSObject();
|
|
223
|
+
String PUSH = "push";
|
|
224
|
+
ret.put(PUSH, IndigitallCp.getPush(getContext(), getActivity().getIntent()));
|
|
225
|
+
call.resolve(ret);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@PluginMethod
|
|
229
|
+
public void logIn(PluginCall call) {
|
|
230
|
+
String EXTERNAL_ID = "externalId";
|
|
231
|
+
String externalId = call.getString(EXTERNAL_ID);
|
|
232
|
+
IndigitallCp.logIn(getContext(), externalId, new DeviceCallback(getContext()) {
|
|
233
|
+
@Override
|
|
234
|
+
public void onSuccess(Device device) {
|
|
235
|
+
JSObject ret = new JSObject();
|
|
236
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
237
|
+
call.resolve(ret);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@Override
|
|
241
|
+
public void onFail(Error error) {
|
|
242
|
+
call.reject(error.getErrorMessage());
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@PluginMethod
|
|
248
|
+
public void logOut(PluginCall call) {
|
|
249
|
+
IndigitallCp.logOut(getContext(), new DeviceCallback(getContext()) {
|
|
250
|
+
@Override
|
|
251
|
+
public void onSuccess(Device device) {
|
|
252
|
+
JSObject ret = new JSObject();
|
|
253
|
+
ret.put(DEVICE, IndigitallParse.jsonFromDevice(device));
|
|
254
|
+
call.resolve(ret);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@Override
|
|
258
|
+
public void onFail(Error error) {
|
|
259
|
+
call.reject(error.getErrorMessage());
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
package com.indigitall.capacitor;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.getcapacitor.JSArray;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.Plugin;
|
|
8
|
+
import com.getcapacitor.PluginCall;
|
|
9
|
+
import com.getcapacitor.PluginMethod;
|
|
10
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
|
+
import com.indigitall.android.commons.models.Error;
|
|
12
|
+
import com.indigitall.android.customer.callbacks.CustomerCallback;
|
|
13
|
+
import com.indigitall.android.customer.callbacks.CustomerFieldCallback;
|
|
14
|
+
import com.indigitall.android.customer.models.Customer;
|
|
15
|
+
import com.indigitall.android.customer.models.CustomerField;
|
|
16
|
+
import com.indigitall.capacitor.utils.IndigitallParse;
|
|
17
|
+
import com.indigitall.capacitor.implementations.CustomerCp;
|
|
18
|
+
|
|
19
|
+
import org.json.JSONException;
|
|
20
|
+
|
|
21
|
+
import java.util.ArrayList;
|
|
22
|
+
|
|
23
|
+
@CapacitorPlugin(name = "CustomerCp")
|
|
24
|
+
public class IndigitallCustomerPlugin extends Plugin {
|
|
25
|
+
|
|
26
|
+
private String CUSTOMER = "customer";
|
|
27
|
+
private String CUSTOMER_FIELD = "customerField";
|
|
28
|
+
private String FIELD_NAMES_LIST = "fieldNamesList";
|
|
29
|
+
private String CUSTOMER_FIELDS = "customerFields";
|
|
30
|
+
private String LINK = "link";
|
|
31
|
+
private String UNLINK = "unlink";
|
|
32
|
+
|
|
33
|
+
@PluginMethod
|
|
34
|
+
public void getCustomer(PluginCall call){
|
|
35
|
+
CustomerCp.getCustomer(getContext(), new CustomerCallback(getContext()) {
|
|
36
|
+
@Override
|
|
37
|
+
public void onSuccess(@NonNull Customer customer) {
|
|
38
|
+
JSObject ret = new JSObject();
|
|
39
|
+
ret.put(CUSTOMER, IndigitallParse.jsonFromCustomer(customer));
|
|
40
|
+
call.resolve(ret);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Override
|
|
44
|
+
public void onError(Error error) {
|
|
45
|
+
call.reject(error.getErrorMessage());
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@PluginMethod
|
|
51
|
+
public void getCustomerInformation(PluginCall call){
|
|
52
|
+
JSArray array = call.getArray(FIELD_NAMES_LIST);
|
|
53
|
+
CustomerCp.getCustomerInformation(getContext(), array, new CustomerFieldCallback(getContext()) {
|
|
54
|
+
@Override
|
|
55
|
+
public void onSuccess(@NonNull ArrayList<CustomerField> arrayList) {
|
|
56
|
+
JSObject ret = new JSObject();
|
|
57
|
+
ret.put(CUSTOMER_FIELD, IndigitallParse.jsonFromCustomerField(arrayList));
|
|
58
|
+
call.resolve(ret);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Override
|
|
62
|
+
public void onError(Error error) {
|
|
63
|
+
call.reject(error.getErrorMessage());
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@PluginMethod
|
|
69
|
+
public void assignOrUpdateValueToCustomerFields(PluginCall call) throws JSONException {
|
|
70
|
+
JSObject obj = call.getObject(CUSTOMER_FIELDS);
|
|
71
|
+
if (obj != null) {
|
|
72
|
+
CustomerCp.assignOrUpdateValueToCustomerFields(getContext(), obj, new CustomerCallback(getContext()) {
|
|
73
|
+
@Override
|
|
74
|
+
public void onSuccess(@NonNull Customer customer) {
|
|
75
|
+
JSObject ret = new JSObject();
|
|
76
|
+
ret.put(CUSTOMER, IndigitallParse.jsonFromCustomer(customer));
|
|
77
|
+
call.resolve(ret);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
public void onError(Error error) {
|
|
82
|
+
call.reject(error.getErrorMessage());
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@PluginMethod
|
|
89
|
+
public void deleteValuesFromCustomerFields(PluginCall call) {
|
|
90
|
+
JSArray array = call.getArray(FIELD_NAMES_LIST);
|
|
91
|
+
CustomerCp.deleteValuesFromCustomerFields(getContext(), array, new CustomerCallback(getContext()) {
|
|
92
|
+
@Override
|
|
93
|
+
public void onSuccess(@NonNull Customer customer) {
|
|
94
|
+
JSObject ret = new JSObject();
|
|
95
|
+
ret.put(CUSTOMER, IndigitallParse.jsonFromCustomer(customer));
|
|
96
|
+
call.resolve(ret);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Override
|
|
100
|
+
public void onError(Error error) {
|
|
101
|
+
call.reject(error.getErrorMessage());
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@PluginMethod
|
|
107
|
+
public void link(PluginCall call) throws JSONException {
|
|
108
|
+
JSObject param = call.getObject(LINK);
|
|
109
|
+
CustomerCp.link(getContext(), param, new CustomerCallback(getContext()) {
|
|
110
|
+
@Override
|
|
111
|
+
public void onSuccess(@NonNull Customer customer) {
|
|
112
|
+
JSObject ret = new JSObject();
|
|
113
|
+
ret.put(CUSTOMER, IndigitallParse.jsonFromCustomer(customer));
|
|
114
|
+
call.resolve(ret);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public void onError(Error error) {
|
|
119
|
+
call.reject(error.getErrorMessage());
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@PluginMethod
|
|
125
|
+
public void unlink(PluginCall call) throws JSONException {
|
|
126
|
+
JSObject param = call.getObject(LINK);
|
|
127
|
+
CustomerCp.unlink(getContext(), param, new CustomerCallback(getContext()) {
|
|
128
|
+
@Override
|
|
129
|
+
public void onSuccess(@NonNull Customer customer) {
|
|
130
|
+
JSObject ret = new JSObject();
|
|
131
|
+
ret.put(CUSTOMER, IndigitallParse.jsonFromCustomer(customer));
|
|
132
|
+
call.resolve(ret);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Override
|
|
136
|
+
public void onError(Error error) {
|
|
137
|
+
call.reject(error.getErrorMessage());
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
}
|