@capgo/inappbrowser 0.3.0 → 0.3.4
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/CapgoInappbrowser.podspec +1 -1
- package/README.md +4 -4
- package/android/build.gradle +9 -9
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +59 -52
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java +1 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewCallbacks.java +2 -0
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +96 -91
- package/android/src/main/res/layout/activity_browser.xml +1 -1
- package/android/src/main/res/values/browser_theme.xml +3 -0
- package/android/src/main/res/values/styles.xml +2 -10
- package/dist/docs.json +4 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back@2x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Back@3x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Back.imageset/Contents.json +26 -0
- package/ios/Plugin/Assets.xcassets/Contents.json +6 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Contents.json +26 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward.png +0 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@2x.png +0 -0
- package/ios/Plugin/Assets.xcassets/Forward.imageset/Forward@3x.png +0 -0
- package/ios/Plugin/Enums.swift +4 -3
- package/ios/Plugin/InAppBrowserPlugin.swift +37 -38
- package/ios/Plugin/WKWebViewController.swift +152 -152
- package/package.json +19 -14
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@capacitor/core');
|
|
6
4
|
|
|
7
5
|
exports.BackgroundColor = void 0;
|
|
@@ -18,7 +16,7 @@ exports.ToolBarType = void 0;
|
|
|
18
16
|
})(exports.ToolBarType || (exports.ToolBarType = {}));
|
|
19
17
|
|
|
20
18
|
const InAppBrowser = core.registerPlugin('InAppBrowser', {
|
|
21
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.InAppBrowserWeb()),
|
|
19
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.InAppBrowserWeb()),
|
|
22
20
|
});
|
|
23
21
|
|
|
24
22
|
class InAppBrowserWeb extends core.WebPlugin {
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then((m) => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,MAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,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,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC5C,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3C,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -15,7 +15,7 @@ var capacitorInAppBrowser = (function (exports, core) {
|
|
|
15
15
|
})(exports.ToolBarType || (exports.ToolBarType = {}));
|
|
16
16
|
|
|
17
17
|
const InAppBrowser = core.registerPlugin('InAppBrowser', {
|
|
18
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.InAppBrowserWeb()),
|
|
18
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.InAppBrowserWeb()),
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
class InAppBrowserWeb extends core.WebPlugin {
|
|
@@ -44,8 +44,6 @@ var capacitorInAppBrowser = (function (exports, core) {
|
|
|
44
44
|
|
|
45
45
|
exports.InAppBrowser = InAppBrowser;
|
|
46
46
|
|
|
47
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
48
|
-
|
|
49
47
|
return exports;
|
|
50
48
|
|
|
51
49
|
})({}, capacitorExports);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then(m => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BackgroundColor;\n(function (BackgroundColor) {\n BackgroundColor[\"WHITE\"] = \"white\";\n BackgroundColor[\"BLACK\"] = \"black\";\n})(BackgroundColor || (BackgroundColor = {}));\nexport var ToolBarType;\n(function (ToolBarType) {\n ToolBarType[\"ACTIVITY\"] = \"activity\";\n ToolBarType[\"NAVIGATION\"] = \"navigation\";\n ToolBarType[\"BLANK\"] = \"blank\";\n ToolBarType[\"DEFAULT\"] = \"\";\n})(ToolBarType || (ToolBarType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst InAppBrowser = registerPlugin('InAppBrowser', {\n web: () => import('./web').then((m) => new m.InAppBrowserWeb()),\n});\nexport * from './definitions';\nexport { InAppBrowser };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class InAppBrowserWeb extends WebPlugin {\n async open(options) {\n console.log('open', options);\n return options;\n }\n async openWebView(options) {\n console.log('openWebView', options);\n return options;\n }\n async close() {\n console.log('close');\n return;\n }\n async setUrl(options) {\n console.log('setUrl', options.url);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BackgroundColor","ToolBarType","registerPlugin","WebPlugin"],"mappings":";;;AAAWA,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACzC,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;IAC7C,IAAI,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACnC,IAAI,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACVhC,UAAC,YAAY,GAAGC,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,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,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"filename" : "Back.png",
|
|
6
|
+
"scale" : "1x"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"idiom" : "universal",
|
|
10
|
+
"filename" : "Back@2x.png",
|
|
11
|
+
"scale" : "2x"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"idiom" : "universal",
|
|
15
|
+
"filename" : "Back@3x.png",
|
|
16
|
+
"scale" : "3x"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"info" : {
|
|
20
|
+
"version" : 1,
|
|
21
|
+
"author" : "xcode"
|
|
22
|
+
},
|
|
23
|
+
"properties" : {
|
|
24
|
+
"template-rendering-intent" : "template"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"images" : [
|
|
3
|
+
{
|
|
4
|
+
"idiom" : "universal",
|
|
5
|
+
"filename" : "Forward.png",
|
|
6
|
+
"scale" : "1x"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"idiom" : "universal",
|
|
10
|
+
"filename" : "Forward@2x.png",
|
|
11
|
+
"scale" : "2x"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"idiom" : "universal",
|
|
15
|
+
"filename" : "Forward@3x.png",
|
|
16
|
+
"scale" : "3x"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"info" : {
|
|
20
|
+
"version" : 1,
|
|
21
|
+
"author" : "xcode"
|
|
22
|
+
},
|
|
23
|
+
"properties" : {
|
|
24
|
+
"template-rendering-intent" : "template"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/ios/Plugin/Enums.swift
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
//
|
|
8
8
|
|
|
9
9
|
import Foundation
|
|
10
|
+
import UIKit
|
|
10
11
|
|
|
11
12
|
public enum WKWebSource: Equatable {
|
|
12
13
|
case remote(URL)
|
|
13
14
|
case file(URL, access: URL)
|
|
14
15
|
case string(String, base: URL?)
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
public var url: URL? {
|
|
17
18
|
switch self {
|
|
18
19
|
case .remote(let u): return u
|
|
@@ -20,14 +21,14 @@ public enum WKWebSource: Equatable {
|
|
|
20
21
|
default: return nil
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
public var remoteURL: URL? {
|
|
25
26
|
switch self {
|
|
26
27
|
case .remote(let u): return u
|
|
27
28
|
default: return nil
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
public var absoluteString: String? {
|
|
32
33
|
switch self {
|
|
33
34
|
case .remote(let u): return u.absoluteString
|
|
@@ -13,69 +13,68 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
13
13
|
var currentPluginCall: CAPPluginCall?
|
|
14
14
|
var isPresentAfterPageLoad = false
|
|
15
15
|
var webViewController: WKWebViewController?
|
|
16
|
-
|
|
17
|
-
private func setup(){
|
|
16
|
+
|
|
17
|
+
private func setup() {
|
|
18
18
|
self.isSetupDone = true
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
#if swift(>=4.2)
|
|
21
21
|
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil)
|
|
22
22
|
NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive(_:)), name: UIApplication.willResignActiveNotification, object: nil)
|
|
23
23
|
#else
|
|
24
|
-
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name
|
|
25
|
-
NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive(_:)), name
|
|
24
|
+
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: .UIApplicationDidBecomeActive, object: nil)
|
|
25
|
+
NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive(_:)), name: .UIApplicationWillResignActive, object: nil)
|
|
26
26
|
#endif
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
func presentView() {
|
|
30
30
|
self.bridge?.viewController?.present(self.navigationWebViewController!, animated: true, completion: {
|
|
31
31
|
self.currentPluginCall?.resolve()
|
|
32
32
|
})
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
@objc func openWebView(_ call: CAPPluginCall) {
|
|
36
36
|
if !self.isSetupDone {
|
|
37
37
|
self.setup()
|
|
38
38
|
}
|
|
39
39
|
self.currentPluginCall = call
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
guard let urlString = call.getString("url") else {
|
|
42
42
|
call.reject("Must provide a URL to open")
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
if urlString.isEmpty {
|
|
47
47
|
call.reject("URL must not be empty")
|
|
48
48
|
return
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
var disclaimerContent = call.getObject("shareDisclaimer")
|
|
54
|
-
let toolbarType = call.getString("toolbarType")
|
|
54
|
+
let toolbarType = call.getString("toolbarType", "")
|
|
55
55
|
let backgroundColor = call.getString("backgroundColor", "black") == "white" ? UIColor.white : UIColor.black
|
|
56
56
|
if toolbarType != "activity" {
|
|
57
57
|
disclaimerContent = nil
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
DispatchQueue.main.async {
|
|
63
63
|
let url = URL(string: urlString)
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if self.isPresentAfterPageLoad {
|
|
66
66
|
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
67
67
|
} else {
|
|
68
68
|
self.webViewController = WKWebViewController.init()
|
|
69
69
|
self.webViewController?.setHeaders(headers: headers)
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
self.webViewController?.source = .remote(url!)
|
|
73
|
-
self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType
|
|
74
|
-
|
|
73
|
+
self.webViewController?.leftNavigaionBarItemTypes = self.getToolbarItems(toolbarType: toolbarType)
|
|
75
74
|
self.webViewController?.toolbarItemTypes = []
|
|
76
75
|
self.webViewController?.doneBarButtonItemPosition = .right
|
|
77
76
|
self.webViewController?.capBrowserPlugin = self
|
|
78
|
-
self.webViewController?.title = call.getString("title"
|
|
77
|
+
self.webViewController?.title = call.getString("title", "")
|
|
79
78
|
self.webViewController?.shareSubject = call.getString("shareSubject")
|
|
80
79
|
self.webViewController?.shareDisclaimer = disclaimerContent
|
|
81
80
|
self.navigationWebViewController = UINavigationController.init(rootViewController: self.webViewController!)
|
|
@@ -92,7 +91,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
|
-
|
|
94
|
+
|
|
96
95
|
func getToolbarItems(toolbarType: String) -> [BarButtonItemType] {
|
|
97
96
|
var result: [BarButtonItemType] = []
|
|
98
97
|
if toolbarType == "activity" {
|
|
@@ -103,7 +102,7 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
103
102
|
}
|
|
104
103
|
return result
|
|
105
104
|
}
|
|
106
|
-
|
|
105
|
+
|
|
107
106
|
@objc func setUrl(_ call: CAPPluginCall) {
|
|
108
107
|
guard let url = call.getString("url") else {
|
|
109
108
|
call.reject("Cannot get new url to set")
|
|
@@ -117,33 +116,33 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
117
116
|
if !self.isSetupDone {
|
|
118
117
|
self.setup()
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
|
|
121
120
|
self.currentPluginCall = call
|
|
122
|
-
|
|
121
|
+
|
|
123
122
|
guard let urlString = call.getString("url") else {
|
|
124
123
|
call.reject("Must provide a URL to open")
|
|
125
124
|
return
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
|
|
128
127
|
if urlString.isEmpty {
|
|
129
128
|
call.reject("URL must not be empty")
|
|
130
129
|
return
|
|
131
130
|
}
|
|
132
|
-
|
|
131
|
+
|
|
133
132
|
let headers = call.getObject("headers", [:]).mapValues { String(describing: $0 as Any) }
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
|
|
136
|
-
|
|
135
|
+
|
|
137
136
|
DispatchQueue.main.async {
|
|
138
137
|
let url = URL(string: urlString)
|
|
139
|
-
|
|
138
|
+
|
|
140
139
|
if self.isPresentAfterPageLoad {
|
|
141
140
|
self.webViewController = WKWebViewController.init(url: url!, headers: headers)
|
|
142
141
|
} else {
|
|
143
142
|
self.webViewController = WKWebViewController.init()
|
|
144
143
|
self.webViewController?.setHeaders(headers: headers)
|
|
145
144
|
}
|
|
146
|
-
|
|
145
|
+
|
|
147
146
|
self.webViewController?.source = .remote(url!)
|
|
148
147
|
self.webViewController?.leftNavigaionBarItemTypes = [.reload]
|
|
149
148
|
self.webViewController?.toolbarItemTypes = [.back, .forward, .activity]
|
|
@@ -160,15 +159,15 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
|
-
|
|
162
|
+
|
|
164
163
|
@objc func close(_ call: CAPPluginCall) {
|
|
165
164
|
DispatchQueue.main.async {
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
self.navigationWebViewController?.dismiss(animated: true, completion: nil)
|
|
166
|
+
call.resolve()
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
|
-
|
|
171
|
-
private func showPrivacyScreen(){
|
|
169
|
+
|
|
170
|
+
private func showPrivacyScreen() {
|
|
172
171
|
if privacyScreen == nil {
|
|
173
172
|
self.privacyScreen = UIImageView()
|
|
174
173
|
if let launchImage = UIImage(named: "LaunchImage") {
|
|
@@ -185,15 +184,15 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
185
184
|
}
|
|
186
185
|
self.navigationWebViewController?.view.addSubview(self.privacyScreen!)
|
|
187
186
|
}
|
|
188
|
-
|
|
189
|
-
private func hidePrivacyScreen(){
|
|
187
|
+
|
|
188
|
+
private func hidePrivacyScreen() {
|
|
190
189
|
self.privacyScreen?.removeFromSuperview()
|
|
191
190
|
}
|
|
192
|
-
|
|
191
|
+
|
|
193
192
|
@objc func appDidBecomeActive(_ notification: NSNotification) {
|
|
194
193
|
self.hidePrivacyScreen()
|
|
195
194
|
}
|
|
196
|
-
|
|
195
|
+
|
|
197
196
|
@objc func appWillResignActive(_ notification: NSNotification) {
|
|
198
197
|
self.showPrivacyScreen()
|
|
199
198
|
}
|