@aigens/aigens-sdk-core 0.0.2 → 0.0.6
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 +32 -0
- package/android/build.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/aigens/sdk/WebContainerActivity.java +199 -10
- package/android/src/main/java/com/aigens/sdk/plugins/CorePlugin.java +76 -1
- package/android/src/main/res/layout/sdk_layout_main.xml +55 -0
- package/dist/docs.json +32 -0
- package/dist/esm/definitions.d.ts +2 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -0
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +12 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +12 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CorePlugin.m +2 -0
- package/ios/Plugin/CorePlugin.swift +78 -19
- package/ios/Plugin/WebContainerViewController.swift +45 -14
- package/package.json +1 -1
package/README.md
CHANGED
@@ -14,7 +14,9 @@ npx cap sync
|
|
14
14
|
<docgen-index>
|
15
15
|
|
16
16
|
* [`echo(...)`](#echo)
|
17
|
+
* [`dismiss(...)`](#dismiss)
|
17
18
|
* [`finish(...)`](#finish)
|
19
|
+
* [`getMember(...)`](#getmember)
|
18
20
|
* [`openBrowser(...)`](#openbrowser)
|
19
21
|
|
20
22
|
</docgen-index>
|
@@ -37,6 +39,21 @@ echo(options: any) => Promise<any>
|
|
37
39
|
--------------------
|
38
40
|
|
39
41
|
|
42
|
+
### dismiss(...)
|
43
|
+
|
44
|
+
```typescript
|
45
|
+
dismiss(options: any) => Promise<any>
|
46
|
+
```
|
47
|
+
|
48
|
+
| Param | Type |
|
49
|
+
| ------------- | ---------------- |
|
50
|
+
| **`options`** | <code>any</code> |
|
51
|
+
|
52
|
+
**Returns:** <code>Promise<any></code>
|
53
|
+
|
54
|
+
--------------------
|
55
|
+
|
56
|
+
|
40
57
|
### finish(...)
|
41
58
|
|
42
59
|
```typescript
|
@@ -52,6 +69,21 @@ finish(options: any) => Promise<any>
|
|
52
69
|
--------------------
|
53
70
|
|
54
71
|
|
72
|
+
### getMember(...)
|
73
|
+
|
74
|
+
```typescript
|
75
|
+
getMember(options: any) => Promise<any>
|
76
|
+
```
|
77
|
+
|
78
|
+
| Param | Type |
|
79
|
+
| ------------- | ---------------- |
|
80
|
+
| **`options`** | <code>any</code> |
|
81
|
+
|
82
|
+
**Returns:** <code>Promise<any></code>
|
83
|
+
|
84
|
+
--------------------
|
85
|
+
|
86
|
+
|
55
87
|
### openBrowser(...)
|
56
88
|
|
57
89
|
```typescript
|
package/android/build.gradle
CHANGED
@@ -52,6 +52,7 @@ dependencies {
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
53
53
|
implementation project(':capacitor-android')
|
54
54
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
55
|
+
|
55
56
|
testImplementation "junit:junit:$junitVersion"
|
56
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
57
58
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
@@ -2,13 +2,26 @@ package com.aigens.sdk;
|
|
2
2
|
|
3
3
|
import android.content.Intent;
|
4
4
|
import android.content.res.AssetManager;
|
5
|
+
import android.graphics.Bitmap;
|
6
|
+
import android.net.Uri;
|
5
7
|
import android.os.Bundle;
|
6
|
-
|
8
|
+
import android.view.View;
|
9
|
+
import android.webkit.WebResourceError;
|
10
|
+
import android.webkit.WebResourceRequest;
|
11
|
+
import android.webkit.WebResourceResponse;
|
12
|
+
import android.webkit.WebView;
|
13
|
+
import android.webkit.WebViewClient;
|
14
|
+
import android.widget.Button;
|
15
|
+
|
16
|
+
import com.aigens.sdk.plugins.CorePlugin;
|
17
|
+
import com.getcapacitor.Bridge;
|
7
18
|
import com.getcapacitor.BridgeActivity;
|
19
|
+
import com.getcapacitor.BridgeWebViewClient;
|
8
20
|
import com.getcapacitor.CapConfig;
|
9
21
|
import com.getcapacitor.Plugin;
|
10
22
|
import com.getcapacitor.PluginLoadException;
|
11
23
|
import com.getcapacitor.PluginManager;
|
24
|
+
import com.aigens.sdk.R;
|
12
25
|
|
13
26
|
import org.json.JSONException;
|
14
27
|
import org.json.JSONObject;
|
@@ -19,9 +32,26 @@ import java.io.InputStream;
|
|
19
32
|
import java.io.InputStreamReader;
|
20
33
|
import java.util.ArrayList;
|
21
34
|
import java.util.List;
|
35
|
+
import java.util.Map;
|
22
36
|
|
23
37
|
public class WebContainerActivity extends BridgeActivity {
|
24
38
|
|
39
|
+
private boolean DEBUG = CorePlugin.DEBUG;
|
40
|
+
private String url;
|
41
|
+
private boolean navbar = false;
|
42
|
+
private Map member;
|
43
|
+
|
44
|
+
private void debug(Object... msgs){
|
45
|
+
|
46
|
+
|
47
|
+
if(DEBUG){
|
48
|
+
for(Object m: msgs){
|
49
|
+
System.out.println(m);
|
50
|
+
}
|
51
|
+
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
25
55
|
|
26
56
|
|
27
57
|
@Override
|
@@ -29,17 +59,34 @@ public class WebContainerActivity extends BridgeActivity {
|
|
29
59
|
|
30
60
|
super.onCreate(savedInstanceState);
|
31
61
|
|
62
|
+
setContentView(R.layout.sdk_layout_main);
|
63
|
+
|
32
64
|
Intent intent = getIntent();
|
33
|
-
|
65
|
+
this.url = intent.getStringExtra("url");
|
34
66
|
|
35
|
-
|
67
|
+
//if navbar = true, show nav bar with "Done" button
|
68
|
+
this.navbar = intent.getBooleanExtra("navbar", false);
|
36
69
|
|
37
|
-
|
70
|
+
this.member = (Map) intent.getSerializableExtra("member");
|
71
|
+
|
72
|
+
if(this.member != null) {
|
73
|
+
CorePlugin.setMember(this.member);
|
74
|
+
}
|
75
|
+
|
76
|
+
System.out.println("OPEN URL:"+ url);
|
77
|
+
|
78
|
+
if(url == null){
|
38
79
|
System.err.println("CONFIG ERROR MISSING NATIVE URL");
|
39
80
|
}
|
40
81
|
|
82
|
+
if(member != null){
|
83
|
+
debug("member", member);
|
84
|
+
}
|
85
|
+
|
41
86
|
JSONObject config = readConfig();
|
42
87
|
|
88
|
+
debug("config", config);
|
89
|
+
|
43
90
|
JSONObject server = config.optJSONObject("server");
|
44
91
|
|
45
92
|
try {
|
@@ -47,6 +94,9 @@ public class WebContainerActivity extends BridgeActivity {
|
|
47
94
|
server.putOpt("url", url);
|
48
95
|
}
|
49
96
|
|
97
|
+
//need to set this to avoid loading ServiceWorker
|
98
|
+
config.put("appendUserAgent", "AigensSDK");
|
99
|
+
|
50
100
|
} catch (JSONException e) {
|
51
101
|
e.printStackTrace();
|
52
102
|
}
|
@@ -60,7 +110,6 @@ public class WebContainerActivity extends BridgeActivity {
|
|
60
110
|
for(Class c: auto){
|
61
111
|
|
62
112
|
String clsName = c.getName();
|
63
|
-
System.err.println("auto loaded plugins:" + clsName);
|
64
113
|
|
65
114
|
if(clsName.endsWith("SplashScreenPlugin")){
|
66
115
|
//don't add the splash screen plugin so it doesn't show the splash screen again
|
@@ -70,15 +119,71 @@ public class WebContainerActivity extends BridgeActivity {
|
|
70
119
|
|
71
120
|
}
|
72
121
|
|
73
|
-
|
122
|
+
debug("App plugins:" + plugins);
|
74
123
|
|
75
|
-
|
76
|
-
//plugins.add(AppPlugin.class);
|
77
|
-
//plugins.add(GeolocationPlugin.class);
|
124
|
+
super.init(savedInstanceState, plugins, cc);
|
78
125
|
|
126
|
+
//still have time to override webview client to avoid any intercept
|
79
127
|
|
128
|
+
BypassWebViewClient wvc = new BypassWebViewClient(this.bridge);
|
129
|
+
this.bridge.getWebView().setWebViewClient(wvc);
|
80
130
|
|
81
|
-
|
131
|
+
initView();
|
132
|
+
initLayout(false, true, false);
|
133
|
+
}
|
134
|
+
|
135
|
+
private void initView(){
|
136
|
+
|
137
|
+
Button backButton = (Button) findViewById(R.id.back);
|
138
|
+
backButton.setOnClickListener(new View.OnClickListener() {
|
139
|
+
@Override
|
140
|
+
public void onClick(View arg0) {
|
141
|
+
|
142
|
+
debug("Back Clicked");
|
143
|
+
WebContainerActivity.this.finish();
|
144
|
+
}
|
145
|
+
});
|
146
|
+
|
147
|
+
Button reloadButton = (Button) findViewById(R.id.reload);
|
148
|
+
reloadButton.setOnClickListener(new View.OnClickListener() {
|
149
|
+
@Override
|
150
|
+
public void onClick(View arg0) {
|
151
|
+
|
152
|
+
debug("Reload Clicked");
|
153
|
+
reload();
|
154
|
+
}
|
155
|
+
});
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
private void reload(){
|
160
|
+
|
161
|
+
String url = this.url;
|
162
|
+
|
163
|
+
/*
|
164
|
+
if(DEBUG){
|
165
|
+
url = "https://test.order.place/test/app/store/500?nocache=true";
|
166
|
+
}*/
|
167
|
+
|
168
|
+
this.initLayout(false, true, false);
|
169
|
+
this.bridge.getWebView().reload();
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
private void initLayout(boolean showWeb, boolean showInfo, boolean showError){
|
174
|
+
|
175
|
+
if(showError){
|
176
|
+
showWeb = false;
|
177
|
+
showInfo = false;
|
178
|
+
}
|
179
|
+
|
180
|
+
View info = findViewById(R.id.info);
|
181
|
+
info.setVisibility(showInfo ? View.VISIBLE : View.INVISIBLE);
|
182
|
+
|
183
|
+
View error = findViewById(R.id.error);
|
184
|
+
error.setVisibility(showError ? View.VISIBLE : View.INVISIBLE);
|
185
|
+
|
186
|
+
bridge.getWebView().setVisibility(showWeb ? View.VISIBLE : View.INVISIBLE);
|
82
187
|
|
83
188
|
|
84
189
|
}
|
@@ -146,4 +251,88 @@ public class WebContainerActivity extends BridgeActivity {
|
|
146
251
|
}
|
147
252
|
}
|
148
253
|
|
254
|
+
//BridgeWebViewClient
|
255
|
+
class BypassWebViewClient extends BridgeWebViewClient {
|
256
|
+
|
257
|
+
public BypassWebViewClient(Bridge bridge) {
|
258
|
+
super(bridge);
|
259
|
+
}
|
260
|
+
|
261
|
+
//somehow this must call parent, otherwise plugins won't work
|
262
|
+
@Override
|
263
|
+
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
264
|
+
|
265
|
+
|
266
|
+
String url = request.getUrl().toString();
|
267
|
+
//debug("shouldInterceptRequest", url);
|
268
|
+
|
269
|
+
|
270
|
+
if(url.indexOf("//scan") > 0){
|
271
|
+
return null;
|
272
|
+
}
|
273
|
+
|
274
|
+
return super.shouldInterceptRequest(view, request);
|
275
|
+
|
276
|
+
//super.shouldInterceptRequest(view, request);
|
277
|
+
//return null;
|
278
|
+
}
|
279
|
+
|
280
|
+
|
281
|
+
@Override
|
282
|
+
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
283
|
+
debug("shouldOverrideUrlLoading", request.getUrl());
|
284
|
+
//Uri url = request.getUrl();
|
285
|
+
|
286
|
+
//return super.shouldOverrideUrlLoading(view, request);
|
287
|
+
|
288
|
+
return false;
|
289
|
+
}
|
290
|
+
|
291
|
+
@Override
|
292
|
+
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
293
|
+
debug("shouldOverrideUrlLoading", url);
|
294
|
+
//return bridge.launchIntent(Uri.parse(url));
|
295
|
+
|
296
|
+
//return super.shouldOverrideUrlLoading(view, url);
|
297
|
+
|
298
|
+
return false;
|
299
|
+
}
|
300
|
+
|
301
|
+
@Override
|
302
|
+
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
303
|
+
|
304
|
+
debug("onPageStarted", url);
|
305
|
+
|
306
|
+
super.onPageStarted(view, url, favicon);
|
307
|
+
|
308
|
+
//bridge.getWebView().setVisibility(View.VISIBLE);
|
309
|
+
initLayout(true, false, false);
|
310
|
+
}
|
311
|
+
|
312
|
+
@Override
|
313
|
+
public void onPageFinished (WebView view, String url){
|
314
|
+
|
315
|
+
debug("onPageFinished", url);
|
316
|
+
//bridge.getWebView().setVisibility(View.VISIBLE);
|
317
|
+
}
|
318
|
+
|
319
|
+
@Override
|
320
|
+
public void onReceivedError (WebView view, int errorCode, String description, String failingUrl){
|
321
|
+
debug("onReceivedErrorOld", errorCode, description, failingUrl);
|
322
|
+
|
323
|
+
initLayout(false, true, true);
|
324
|
+
}
|
325
|
+
|
326
|
+
/*
|
327
|
+
@Override
|
328
|
+
public void onReceivedError (WebView view,
|
329
|
+
WebResourceRequest request,
|
330
|
+
WebResourceError error){
|
331
|
+
|
332
|
+
debug("onReceivedError2", request.getUrl());
|
333
|
+
}*/
|
334
|
+
}
|
335
|
+
|
336
|
+
|
337
|
+
|
149
338
|
}
|
@@ -3,6 +3,9 @@ package com.aigens.sdk.plugins;
|
|
3
3
|
import android.app.Activity;
|
4
4
|
import android.content.Intent;
|
5
5
|
|
6
|
+
import androidx.activity.result.ActivityResultLauncher;
|
7
|
+
import androidx.appcompat.app.AppCompatActivity;
|
8
|
+
|
6
9
|
import com.aigens.sdk.WebContainerActivity;
|
7
10
|
import com.getcapacitor.JSObject;
|
8
11
|
import com.getcapacitor.Plugin;
|
@@ -10,18 +13,64 @@ import com.getcapacitor.PluginCall;
|
|
10
13
|
import com.getcapacitor.PluginMethod;
|
11
14
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
12
15
|
|
16
|
+
import org.json.JSONException;
|
17
|
+
|
18
|
+
import java.io.Serializable;
|
19
|
+
import java.util.HashMap;
|
20
|
+
import java.util.Iterator;
|
21
|
+
import java.util.Map;
|
22
|
+
|
13
23
|
@CapacitorPlugin(name = "Core")
|
14
24
|
public class CorePlugin extends Plugin {
|
15
25
|
|
26
|
+
public static boolean DEBUG = true;
|
27
|
+
|
28
|
+
private static Map member;
|
29
|
+
|
30
|
+
private void debug(Object msg){
|
31
|
+
|
32
|
+
if(DEBUG){
|
33
|
+
System.out.println(msg);
|
34
|
+
}
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
public static void setMember(Map member){
|
39
|
+
CorePlugin.member = member;
|
40
|
+
}
|
41
|
+
|
42
|
+
@Override
|
43
|
+
protected void handleOnStart(){
|
44
|
+
|
45
|
+
}
|
46
|
+
|
16
47
|
@PluginMethod()
|
17
48
|
public void echo(PluginCall call) {
|
18
49
|
String value = call.getString("value");
|
19
50
|
|
51
|
+
debug("CorePlugin echo:" + value);
|
52
|
+
|
20
53
|
JSObject ret = new JSObject();
|
21
54
|
ret.put("value", value);
|
22
55
|
call.resolve(ret);
|
23
56
|
}
|
24
57
|
|
58
|
+
@PluginMethod()
|
59
|
+
public void getMember(PluginCall call) {
|
60
|
+
|
61
|
+
debug("CorePlugin getMember:" + member);
|
62
|
+
|
63
|
+
JSObject ret = new JSObject();
|
64
|
+
ret.put("member", member);
|
65
|
+
call.resolve(ret);
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
// Launch
|
70
|
+
//public void onButtonClick(View view) {
|
71
|
+
// barcodeLauncher.launch(new ScanOptions());
|
72
|
+
//}
|
73
|
+
|
25
74
|
@PluginMethod()
|
26
75
|
public void finish(PluginCall call) {
|
27
76
|
|
@@ -29,6 +78,13 @@ public class CorePlugin extends Plugin {
|
|
29
78
|
|
30
79
|
}
|
31
80
|
|
81
|
+
@PluginMethod()
|
82
|
+
public void dismiss(PluginCall call) {
|
83
|
+
|
84
|
+
getActivity().finish();
|
85
|
+
|
86
|
+
}
|
87
|
+
|
32
88
|
@PluginMethod()
|
33
89
|
public void openBrowser(PluginCall call) {
|
34
90
|
|
@@ -37,12 +93,31 @@ public class CorePlugin extends Plugin {
|
|
37
93
|
if(url == null) return;
|
38
94
|
|
39
95
|
JSObject options = call.getObject("options", null);
|
96
|
+
JSObject member = call.getObject("member", null);
|
97
|
+
|
98
|
+
Map memMap = new HashMap();
|
99
|
+
|
100
|
+
if(member != null){
|
101
|
+
Iterator<String> iter = member.keys();
|
102
|
+
while(iter.hasNext()){
|
103
|
+
String k = iter.next();
|
104
|
+
try {
|
105
|
+
Object v = member.get(k);
|
106
|
+
memMap.put(k, v);
|
107
|
+
} catch (JSONException e) {
|
108
|
+
e.printStackTrace();
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
}
|
40
113
|
|
41
114
|
Activity act = getActivity();
|
42
115
|
|
43
116
|
Intent intent = new Intent(act, WebContainerActivity.class);
|
44
117
|
|
45
|
-
intent.putExtra("
|
118
|
+
intent.putExtra("url", url);
|
119
|
+
intent.putExtra("member", (Serializable) memMap);
|
120
|
+
|
46
121
|
act.startActivity(intent);
|
47
122
|
|
48
123
|
JSObject ret = new JSObject();
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
5
|
+
android:layout_width="match_parent"
|
6
|
+
android:layout_height="match_parent"
|
7
|
+
tools:context="com.getcapacitor.BridgeActivity"
|
8
|
+
>
|
9
|
+
|
10
|
+
<com.getcapacitor.CapacitorWebView
|
11
|
+
android:id="@+id/webview"
|
12
|
+
android:layout_width="fill_parent"
|
13
|
+
android:layout_height="fill_parent">
|
14
|
+
|
15
|
+
</com.getcapacitor.CapacitorWebView>
|
16
|
+
|
17
|
+
<LinearLayout
|
18
|
+
android:id="@+id/info"
|
19
|
+
android:layout_width="match_parent"
|
20
|
+
android:layout_height="match_parent"
|
21
|
+
android:gravity="center"
|
22
|
+
android:orientation="vertical">
|
23
|
+
|
24
|
+
<ProgressBar
|
25
|
+
android:id="@+id/progress"
|
26
|
+
style="?android:attr/progressBarStyle"
|
27
|
+
android:layout_width="match_parent"
|
28
|
+
android:layout_height="wrap_content" />
|
29
|
+
|
30
|
+
</LinearLayout>
|
31
|
+
|
32
|
+
<LinearLayout
|
33
|
+
android:id="@+id/error"
|
34
|
+
android:layout_width="match_parent"
|
35
|
+
android:layout_height="match_parent"
|
36
|
+
android:gravity="center"
|
37
|
+
android:orientation="horizontal">
|
38
|
+
|
39
|
+
<Button
|
40
|
+
android:id="@+id/back"
|
41
|
+
android:layout_width="wrap_content"
|
42
|
+
android:layout_height="wrap_content"
|
43
|
+
android:layout_marginRight="8dp"
|
44
|
+
android:text="Exit" />
|
45
|
+
|
46
|
+
<Button
|
47
|
+
android:id="@+id/reload"
|
48
|
+
android:layout_width="wrap_content"
|
49
|
+
android:layout_height="wrap_content"
|
50
|
+
android:text="Reload" />
|
51
|
+
|
52
|
+
</LinearLayout>
|
53
|
+
|
54
|
+
|
55
|
+
</FrameLayout>
|
package/dist/docs.json
CHANGED
@@ -21,6 +21,22 @@
|
|
21
21
|
"complexTypes": [],
|
22
22
|
"slug": "echo"
|
23
23
|
},
|
24
|
+
{
|
25
|
+
"name": "dismiss",
|
26
|
+
"signature": "(options: any) => Promise<any>",
|
27
|
+
"parameters": [
|
28
|
+
{
|
29
|
+
"name": "options",
|
30
|
+
"docs": "",
|
31
|
+
"type": "any"
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"returns": "Promise<any>",
|
35
|
+
"tags": [],
|
36
|
+
"docs": "",
|
37
|
+
"complexTypes": [],
|
38
|
+
"slug": "dismiss"
|
39
|
+
},
|
24
40
|
{
|
25
41
|
"name": "finish",
|
26
42
|
"signature": "(options: any) => Promise<any>",
|
@@ -37,6 +53,22 @@
|
|
37
53
|
"complexTypes": [],
|
38
54
|
"slug": "finish"
|
39
55
|
},
|
56
|
+
{
|
57
|
+
"name": "getMember",
|
58
|
+
"signature": "(options: any) => Promise<any>",
|
59
|
+
"parameters": [
|
60
|
+
{
|
61
|
+
"name": "options",
|
62
|
+
"docs": "",
|
63
|
+
"type": "any"
|
64
|
+
}
|
65
|
+
],
|
66
|
+
"returns": "Promise<any>",
|
67
|
+
"tags": [],
|
68
|
+
"docs": "",
|
69
|
+
"complexTypes": [],
|
70
|
+
"slug": "getmember"
|
71
|
+
},
|
40
72
|
{
|
41
73
|
"name": "openBrowser",
|
42
74
|
"signature": "(options: any) => Promise<any>",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CorePlugin {\n echo(options: any): Promise<any>;\n finish(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n}\n"]}
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CorePlugin {\n echo(options: any): Promise<any>;\n dismiss(options: any): Promise<any>;\n finish(options: any): Promise<any>;\n getMember(options: any): Promise<any>;\n openBrowser(options: any): Promise<any>;\n\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
@@ -2,6 +2,8 @@ import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
import type { CorePlugin } from './definitions';
|
3
3
|
export declare class CoreWeb extends WebPlugin implements CorePlugin {
|
4
4
|
echo(options: any): Promise<any>;
|
5
|
+
getMember(options: any): Promise<any>;
|
6
|
+
dismiss(options: any): Promise<any>;
|
5
7
|
finish(options: any): Promise<any>;
|
6
8
|
openBrowser(options: any): Promise<any>;
|
7
9
|
}
|
package/dist/esm/web.js
CHANGED
@@ -4,6 +4,18 @@ export class CoreWeb extends WebPlugin {
|
|
4
4
|
console.log('ECHO', options);
|
5
5
|
return options;
|
6
6
|
}
|
7
|
+
async getMember(options) {
|
8
|
+
var _a, _b;
|
9
|
+
console.log('GET MEMBER', options);
|
10
|
+
var result = {};
|
11
|
+
var w = window;
|
12
|
+
result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
|
13
|
+
return result;
|
14
|
+
}
|
15
|
+
async dismiss(options) {
|
16
|
+
console.log('DISMISS', options);
|
17
|
+
return options;
|
18
|
+
}
|
7
19
|
async finish(options) {
|
8
20
|
console.log('FINISH', options);
|
9
21
|
return options;
|
package/dist/esm/web.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAY;QACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAY;QAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,OAAQ,SAAQ,SAAS;IAClC,KAAK,CAAC,IAAI,CAAC,OAAY;QACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAY;;QACxB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAS,CAAC;QACvB,IAAI,CAAC,GAAG,MAAa,CAAC;QACtB,MAAM,CAAC,MAAM,eAAG,CAAC,CAAC,MAAM,0CAAE,OAAO,0CAAE,MAAM,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAY;QACtB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAY;QACrB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAY;QAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;CAGJ","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { CorePlugin } from './definitions';\n\n\nexport class CoreWeb extends WebPlugin implements CorePlugin {\n async echo(options: any): Promise<any> {\n console.log('ECHO', options);\n return options;\n }\n\n async getMember(options: any): Promise<any> {\n console.log('GET MEMBER', options);\n var result = {} as any;\n var w = window as any;\n result.member = w.aigens?.context?.member;\n return result;\n }\n\n async dismiss(options: any): Promise<any> {\n console.log('DISMISS', options);\n return options;\n }\n\n async finish(options: any): Promise<any> {\n console.log('FINISH', options);\n return options;\n }\n\n async openBrowser(options: any): Promise<any> {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n\n\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
@@ -13,6 +13,18 @@ class CoreWeb extends core.WebPlugin {
|
|
13
13
|
console.log('ECHO', options);
|
14
14
|
return options;
|
15
15
|
}
|
16
|
+
async getMember(options) {
|
17
|
+
var _a, _b;
|
18
|
+
console.log('GET MEMBER', options);
|
19
|
+
var result = {};
|
20
|
+
var w = window;
|
21
|
+
result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
|
22
|
+
return result;
|
23
|
+
}
|
24
|
+
async dismiss(options) {
|
25
|
+
console.log('DISMISS', options);
|
26
|
+
return options;
|
27
|
+
}
|
16
28
|
async finish(options) {
|
17
29
|
console.log('FINISH', options);
|
18
30
|
return options;
|
package/dist/plugin.cjs.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;AACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;AACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;AACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;AAC9I,QAAQ,OAAO,MAAM,CAAC;AACtB,KAAK;AACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;AAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
@@ -10,6 +10,18 @@ var capacitorCore = (function (exports, core) {
|
|
10
10
|
console.log('ECHO', options);
|
11
11
|
return options;
|
12
12
|
}
|
13
|
+
async getMember(options) {
|
14
|
+
var _a, _b;
|
15
|
+
console.log('GET MEMBER', options);
|
16
|
+
var result = {};
|
17
|
+
var w = window;
|
18
|
+
result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;
|
19
|
+
return result;
|
20
|
+
}
|
21
|
+
async dismiss(options) {
|
22
|
+
console.log('DISMISS', options);
|
23
|
+
return options;
|
24
|
+
}
|
13
25
|
async finish(options) {
|
14
26
|
console.log('FINISH', options);
|
15
27
|
return options;
|
package/dist/plugin.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Core = registerPlugin('Core', {\n web: () => import('./web').then(m => new m.CoreWeb()),\n});\nexport * from './definitions';\nexport { Core };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CoreWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async getMember(options) {\n var _a, _b;\n console.log('GET MEMBER', options);\n var result = {};\n var w = window;\n result.member = (_b = (_a = w.aigens) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.member;\n return result;\n }\n async dismiss(options) {\n console.log('DISMISS', options);\n return options;\n }\n async finish(options) {\n console.log('FINISH', options);\n return options;\n }\n async openBrowser(options) {\n console.log(options);\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;IAC7B,QAAQ,IAAI,EAAE,EAAE,EAAE,CAAC;IACnB,QAAQ,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,IAAI,MAAM,GAAG,EAAE,CAAC;IACxB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;IACvB,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAC9I,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE;IAC3B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
package/ios/Plugin/CorePlugin.m
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
6
6
|
CAP_PLUGIN(CorePlugin, "Core",
|
7
7
|
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
|
8
|
+
CAP_PLUGIN_METHOD(dismiss, CAPPluginReturnPromise);
|
8
9
|
CAP_PLUGIN_METHOD(finish, CAPPluginReturnPromise);
|
9
10
|
CAP_PLUGIN_METHOD(openBrowser, CAPPluginReturnPromise);
|
11
|
+
CAP_PLUGIN_METHOD(getMember, CAPPluginReturnPromise);
|
10
12
|
)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import Foundation
|
2
2
|
import Capacitor
|
3
|
+
import UIKit
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Please read the Capacitor iOS Plugin Development Guide
|
@@ -7,65 +8,123 @@ import Capacitor
|
|
7
8
|
*/
|
8
9
|
@objc(CorePlugin)
|
9
10
|
public class CorePlugin: CAPPlugin {
|
11
|
+
|
10
12
|
private let implementation = Core()
|
11
|
-
|
13
|
+
public static var member: Dictionary<String, Any>?
|
14
|
+
|
12
15
|
@objc func echo(_ call: CAPPluginCall) {
|
13
|
-
|
14
|
-
print("
|
16
|
+
|
17
|
+
print("CorePlugin echo")
|
15
18
|
|
16
19
|
let value = call.getString("value") ?? ""
|
17
20
|
call.resolve([
|
18
21
|
"value": implementation.echo(value)
|
19
22
|
])
|
23
|
+
|
24
|
+
|
20
25
|
}
|
21
26
|
|
22
|
-
|
23
|
-
@objc func finish(_ call: CAPPluginCall) {
|
24
|
-
|
25
|
-
print("FINISH CALLED")
|
27
|
+
@objc func dismiss(_ call: CAPPluginCall) {
|
26
28
|
|
29
|
+
print("CorePlugin dismiss")
|
30
|
+
|
27
31
|
DispatchQueue.main.async {
|
28
32
|
self.bridge?.viewController?.dismiss(animated: true);
|
29
33
|
}
|
34
|
+
|
35
|
+
|
36
|
+
//let value = call.getString("value") ?? ""
|
37
|
+
call.resolve([
|
38
|
+
"success": true
|
39
|
+
//"value": implementation.echo(value)
|
40
|
+
])
|
30
41
|
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
@objc func getMember(_ call: CAPPluginCall) {
|
46
|
+
|
47
|
+
call.resolve([
|
48
|
+
"member": CorePlugin.member!
|
49
|
+
])
|
50
|
+
}
|
51
|
+
|
52
|
+
@objc func finish(_ call: CAPPluginCall) {
|
53
|
+
|
54
|
+
print("CorePlugin finish")
|
31
55
|
|
56
|
+
DispatchQueue.main.async {
|
57
|
+
self.bridge?.viewController?.dismiss(animated: true);
|
58
|
+
}
|
59
|
+
|
60
|
+
|
32
61
|
//let value = call.getString("value") ?? ""
|
33
62
|
call.resolve([
|
34
63
|
"success": true
|
35
64
|
//"value": implementation.echo(value)
|
36
65
|
])
|
37
66
|
}
|
38
|
-
|
39
|
-
|
67
|
+
|
68
|
+
|
40
69
|
@objc func openBrowser(_ call: CAPPluginCall) {
|
70
|
+
|
71
|
+
print("CorePlugin openBrowser")
|
41
72
|
|
42
73
|
let url = call.getString("url")
|
43
|
-
|
44
|
-
|
74
|
+
|
75
|
+
|
45
76
|
if(url == nil){
|
46
77
|
return
|
47
78
|
}
|
48
79
|
|
80
|
+
let member = call.getObject("member")
|
81
|
+
|
49
82
|
DispatchQueue.main.async {
|
50
|
-
|
51
|
-
print("OPEN RUN", url!)
|
52
|
-
|
83
|
+
|
53
84
|
let bridgeVC = WebContainerViewController()
|
54
|
-
|
85
|
+
|
55
86
|
var options = [String: AnyObject]()
|
56
87
|
options["url"] = url as AnyObject;
|
57
|
-
|
58
|
-
bridgeVC.options = options;
|
59
88
|
|
89
|
+
if(member != nil){
|
90
|
+
options["member"] = member as AnyObject;
|
91
|
+
}
|
92
|
+
|
93
|
+
bridgeVC.options = options;
|
94
|
+
|
60
95
|
bridgeVC.modalPresentationStyle = .fullScreen
|
61
96
|
let currentVC = self.bridge?.viewController;
|
62
97
|
currentVC?.present(bridgeVC, animated: true);
|
63
98
|
}
|
64
|
-
|
65
|
-
|
99
|
+
|
100
|
+
|
66
101
|
call.resolve([
|
67
102
|
"success": true
|
68
103
|
//"value": implementation.echo(value)
|
69
104
|
])
|
70
105
|
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
/*
|
111
|
+
@objc func openAppSettings(_ call: CAPPluginCall) {
|
112
|
+
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
|
113
|
+
return
|
114
|
+
}
|
115
|
+
|
116
|
+
DispatchQueue.main.async {
|
117
|
+
if UIApplication.shared.canOpenURL(settingsUrl) {
|
118
|
+
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
|
119
|
+
call.resolve()
|
120
|
+
})
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
*/
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
71
130
|
}
|
@@ -10,36 +10,67 @@ import Capacitor
|
|
10
10
|
|
11
11
|
|
12
12
|
@objc open class WebContainerViewController: CAPBridgeViewController {
|
13
|
-
|
14
|
-
public var options: Dictionary<String,
|
15
|
-
|
13
|
+
|
14
|
+
public var options: Dictionary<String, Any>?
|
15
|
+
|
16
16
|
override open func viewDidLoad() {
|
17
|
-
|
17
|
+
|
18
18
|
print("WebContainerViewController viewDidLoad")
|
19
|
-
|
19
|
+
|
20
20
|
self.becomeFirstResponder()
|
21
21
|
loadWebViewCustom()
|
22
22
|
//loadWebView()
|
23
23
|
}
|
24
|
-
|
25
|
-
|
24
|
+
|
25
|
+
//this method overwrite parent to return a desc with custom config.json
|
26
|
+
override open func instanceDescriptor() -> InstanceDescriptor {
|
27
|
+
|
28
|
+
//print("WebContainerViewController custom instanceDescriptor")
|
29
|
+
|
30
|
+
//let configLoc = Bundle.main.url(forResource: "capacitor.config", withExtension: "json")
|
31
|
+
|
32
|
+
//default config paths
|
33
|
+
var wwwLoc = Bundle.main.url(forResource: "public", withExtension: nil)
|
34
|
+
var configLoc = Bundle.main.url(forResource: "capacitor.config", withExtension: "json")
|
35
|
+
|
36
|
+
//if config is missing, it's a dynamic page, load config from sdk core
|
37
|
+
if(configLoc == nil){
|
38
|
+
configLoc = Bundle(for: WebContainerViewController.self).url(forResource: "capacitor.config", withExtension: "json")
|
39
|
+
|
40
|
+
//www folder will be dynamic, set to anything is ok
|
41
|
+
//wwwLoc = configLoc
|
42
|
+
wwwLoc = FileManager.default.temporaryDirectory
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
let descriptor = InstanceDescriptor.init(at: wwwLoc!, configuration: configLoc, cordovaConfiguration: nil)
|
47
|
+
|
48
|
+
|
49
|
+
return descriptor
|
50
|
+
}
|
51
|
+
|
26
52
|
public final func loadWebViewCustom() {
|
27
|
-
|
53
|
+
|
28
54
|
//let bridge = self.bridge
|
29
55
|
//let plugins = self.bridge["plugins"]
|
30
|
-
|
31
|
-
|
56
|
+
|
57
|
+
|
32
58
|
let urlString = self.options?["url"] as? String;
|
33
59
|
|
34
60
|
if(urlString == nil){
|
35
61
|
return;
|
36
62
|
}
|
37
|
-
|
63
|
+
|
38
64
|
let url = URL(string: urlString!)
|
39
|
-
|
65
|
+
|
66
|
+
let member = self.options?["member"] as? Dictionary<String, Any>
|
67
|
+
|
68
|
+
CorePlugin.member = member
|
69
|
+
|
70
|
+
|
40
71
|
//bridge.webViewDelegationHandler.willLoadWebview(webView)
|
41
72
|
_ = webView?.load(URLRequest(url: url!))
|
42
|
-
|
43
|
-
|
73
|
+
|
74
|
+
|
44
75
|
}
|
45
76
|
}
|