@protobase/mobile 0.94.6 → 0.94.7
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether ProtobaseExternal may open a URL, as the server's tapUrl and the shell check it: at most 2048 characters with
|
|
5
|
+
* no whitespace or control character, parsed as an absolute `http` or `https` URL with a host.
|
|
6
|
+
*/
|
|
7
|
+
enum ExternalUrl {
|
|
8
|
+
private static let refused = CharacterSet.whitespacesAndNewlines.union(.controlCharacters).union(.illegalCharacters)
|
|
9
|
+
|
|
10
|
+
static func allowed(_ text: String?) -> URL? {
|
|
11
|
+
guard let text, text.count <= 2048, text.unicodeScalars.allSatisfy({ !refused.contains($0) }) else { return nil }
|
|
12
|
+
guard let url = URL(string: text), let scheme = url.scheme?.lowercased(), scheme == "https" || scheme == "http" else { return nil }
|
|
13
|
+
guard let host = url.host, !host.isEmpty else { return nil }
|
|
14
|
+
return url
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opens an `http` or `https` URL outside the app, in the app the phone opens links with, such as a notification's url
|
|
6
|
+
* on another origin. Never a navigation of the WebView, which would load the page inside the app.
|
|
7
|
+
*/
|
|
8
|
+
@objc(ProtobaseExternal)
|
|
9
|
+
public class ProtobaseExternal: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
+
public let identifier = "ProtobaseExternal"
|
|
11
|
+
public let jsName = "ProtobaseExternal"
|
|
12
|
+
public let pluginMethods: [CAPPluginMethod] = [CAPPluginMethod(name: "open", returnType: CAPPluginReturnPromise)]
|
|
13
|
+
|
|
14
|
+
@objc func open(_ call: CAPPluginCall) {
|
|
15
|
+
guard let url = ExternalUrl.allowed(call.getString("url")) else {
|
|
16
|
+
call.reject("ProtobaseExternal opens an absolute http or https URL only")
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
DispatchQueue.main.async {
|
|
20
|
+
UIApplication.shared.open(url) { opened in
|
|
21
|
+
if opened { call.resolve() } else { call.reject("No app opens \(url.scheme ?? "") links", "NO_BROWSER") }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Capacitor
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the iOS app registers its APNs token with: the app's bundle id, the topic APNs sends to, and the APNs
|
|
5
|
+
* environment its push entitlement names, which the CLI writes into capacitor.config.json beside it (`sandbox` for a
|
|
6
|
+
* development build, `production` for a release), outside the app's web part.
|
|
7
|
+
*/
|
|
8
|
+
@objc(ProtobasePush)
|
|
9
|
+
public class ProtobasePush: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
+
public let identifier = "ProtobasePush"
|
|
11
|
+
public let jsName = "ProtobasePush"
|
|
12
|
+
public let pluginMethods: [CAPPluginMethod] = [CAPPluginMethod(name: "apns", returnType: CAPPluginReturnPromise)]
|
|
13
|
+
|
|
14
|
+
@objc func apns(_ call: CAPPluginCall) {
|
|
15
|
+
guard let environment = getConfig().getString("environment"), ["sandbox", "production"].contains(environment) else {
|
|
16
|
+
call.reject("The app was built without push")
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
guard let appId = Bundle.main.bundleIdentifier else {
|
|
20
|
+
call.reject("The app has no bundle id")
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
call.resolve(["appId": appId, "environment": environment])
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/mobile",
|
|
3
|
-
"version": "0.94.
|
|
3
|
+
"version": "0.94.7",
|
|
4
4
|
"description": "The Capacitor that protobase mobile builds a Protobase app's iOS and Android projects with, at fixed versions, and the native plugins that keep page script away from the session and give the iOS app its bounce; installed by the CLI on first use.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"android/build.gradle",
|
|
23
23
|
"icon"
|
|
24
24
|
],
|
|
25
|
-
"nativeContract":
|
|
25
|
+
"nativeContract": 10,
|
|
26
26
|
"capacitor": {
|
|
27
27
|
"ios": {
|
|
28
28
|
"src": "ios"
|