use capacitor AppLauncher instead of Browser

This commit is contained in:
Paul Miller
2023-11-10 16:43:11 -06:00
committed by Tony Giorgio
parent 761222c85e
commit 2c4c37c23f
9 changed files with 45 additions and 45 deletions

View File

@@ -11,7 +11,7 @@ apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-mlkit-barcode-scanning')
implementation project(':capacitor-app')
implementation project(':capacitor-browser')
implementation project(':capacitor-app-launcher')
implementation project(':capacitor-clipboard')
implementation project(':capacitor-filesystem')
implementation project(':capacitor-haptics')

View File

@@ -8,8 +8,8 @@ project(':capacitor-mlkit-barcode-scanning').projectDir = new File('../node_modu
include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/.pnpm/@capacitor+app@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app/android')
include ':capacitor-browser'
project(':capacitor-browser').projectDir = new File('../node_modules/.pnpm/@capacitor+browser@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/browser/android')
include ':capacitor-app-launcher'
project(':capacitor-app-launcher').projectDir = new File('../node_modules/.pnpm/@capacitor+app-launcher@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app-launcher/android')
include ':capacitor-clipboard'
project(':capacitor-clipboard').projectDir = new File('../node_modules/.pnpm/@capacitor+clipboard@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/clipboard/android')

View File

@@ -20,6 +20,8 @@
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>13</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
@@ -45,9 +47,11 @@
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>nostr+walletconnect</string>
</array>
</dict>
</plist>

View File

@@ -13,7 +13,7 @@ def capacitor_pods
pod 'CapacitorCordova', :path => '../../node_modules/.pnpm/@capacitor+ios@5.5.1_@capacitor+core@5.5.1/node_modules/@capacitor/ios'
pod 'CapacitorMlkitBarcodeScanning', :path => '../../node_modules/.pnpm/@capacitor-mlkit+barcode-scanning@5.3.0_@capacitor+core@5.5.1/node_modules/@capacitor-mlkit/barcode-scanning'
pod 'CapacitorApp', :path => '../../node_modules/.pnpm/@capacitor+app@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app'
pod 'CapacitorBrowser', :path => '../../node_modules/.pnpm/@capacitor+browser@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/browser'
pod 'CapacitorAppLauncher', :path => '../../node_modules/.pnpm/@capacitor+app-launcher@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app-launcher'
pod 'CapacitorClipboard', :path => '../../node_modules/.pnpm/@capacitor+clipboard@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/clipboard'
pod 'CapacitorFilesystem', :path => '../../node_modules/.pnpm/@capacitor+filesystem@5.1.4_@capacitor+core@5.5.1/node_modules/@capacitor/filesystem'
pod 'CapacitorHaptics', :path => '../../node_modules/.pnpm/@capacitor+haptics@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/haptics'

View File

@@ -3,7 +3,7 @@ PODS:
- CapacitorCordova
- CapacitorApp (5.0.6):
- Capacitor
- CapacitorBrowser (5.0.6):
- CapacitorAppLauncher (5.0.6):
- Capacitor
- CapacitorClipboard (5.0.6):
- Capacitor
@@ -79,7 +79,7 @@ PODS:
DEPENDENCIES:
- "Capacitor (from `../../node_modules/.pnpm/@capacitor+ios@5.5.1_@capacitor+core@5.5.1/node_modules/@capacitor/ios`)"
- "CapacitorApp (from `../../node_modules/.pnpm/@capacitor+app@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app`)"
- "CapacitorBrowser (from `../../node_modules/.pnpm/@capacitor+browser@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/browser`)"
- "CapacitorAppLauncher (from `../../node_modules/.pnpm/@capacitor+app-launcher@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app-launcher`)"
- "CapacitorClipboard (from `../../node_modules/.pnpm/@capacitor+clipboard@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/clipboard`)"
- "CapacitorCordova (from `../../node_modules/.pnpm/@capacitor+ios@5.5.1_@capacitor+core@5.5.1/node_modules/@capacitor/ios`)"
- "CapacitorFilesystem (from `../../node_modules/.pnpm/@capacitor+filesystem@5.1.4_@capacitor+core@5.5.1/node_modules/@capacitor/filesystem`)"
@@ -109,8 +109,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/.pnpm/@capacitor+ios@5.5.1_@capacitor+core@5.5.1/node_modules/@capacitor/ios"
CapacitorApp:
:path: "../../node_modules/.pnpm/@capacitor+app@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app"
CapacitorBrowser:
:path: "../../node_modules/.pnpm/@capacitor+browser@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/browser"
CapacitorAppLauncher:
:path: "../../node_modules/.pnpm/@capacitor+app-launcher@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/app-launcher"
CapacitorClipboard:
:path: "../../node_modules/.pnpm/@capacitor+clipboard@5.0.6_@capacitor+core@5.5.1/node_modules/@capacitor/clipboard"
CapacitorCordova:
@@ -131,7 +131,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Capacitor: 9da0a2415e3b6098511f8b5ffdb578d91ee79f8f
CapacitorApp: 024e1b1bea5f883d79f6330d309bc441c88ad04a
CapacitorBrowser: 6192948e0ce804fd72aaf77f4114a3ad2e08c760
CapacitorAppLauncher: 5a9f06c13c6b4f5d65b550a07128ef04f3a216b3
CapacitorClipboard: 77edf49827ea21da2a9c05c690a4a6a4d07199c4
CapacitorCordova: e128cc7688c070ca0bfa439898a5f609da8dbcfe
CapacitorFilesystem: af704badfbc69f6f8623d9ed313e5490e3723dcb
@@ -153,6 +153,6 @@ SPEC CHECKSUMS:
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PODFILE CHECKSUM: 0fff4697f0ed13fc86b2f815bddfd57238283e54
PODFILE CHECKSUM: 0a4556c3ff620e7baf2e9aeba1f6e9f4fe406a0f
COCOAPODS: 1.10.2

View File

@@ -45,7 +45,7 @@
"@capacitor-mlkit/barcode-scanning": "^5.3.0",
"@capacitor/android": "^5.5.1",
"@capacitor/app": "^5.0.6",
"@capacitor/browser": "5.0.6",
"@capacitor/app-launcher": "^5.0.6",
"@capacitor/clipboard": "^5.0.6",
"@capacitor/core": "^5.5.1",
"@capacitor/filesystem": "^5.1.4",

20
pnpm-lock.yaml generated
View File

@@ -17,8 +17,8 @@ importers:
'@capacitor/app':
specifier: ^5.0.6
version: 5.0.6(@capacitor/core@5.5.1)
'@capacitor/browser':
specifier: 5.0.6
'@capacitor/app-launcher':
specifier: ^5.0.6
version: 5.0.6(@capacitor/core@5.5.1)
'@capacitor/clipboard':
specifier: ^5.0.6
@@ -1503,6 +1503,14 @@ packages:
'@capacitor/core': 5.5.1
dev: false
/@capacitor/app-launcher@5.0.6(@capacitor/core@5.5.1):
resolution: {integrity: sha512-iKF0xvBfYYWVBHL1p0Q10ZecrQDtVZ+nE/1MK2gHLE81ffUwLO+ipDPrDLzAs6SbWwqC/3ORBiI36bjQUbZ/Rw==}
peerDependencies:
'@capacitor/core': ^5.0.0
dependencies:
'@capacitor/core': 5.5.1
dev: false
/@capacitor/app@5.0.6(@capacitor/core@5.5.1):
resolution: {integrity: sha512-6ZXVdnNmaYILasC/RjQw+yfTmq2ZO7Q3v5lFcDVfq3PFGnybyYQh+RstBrYri+376OmXOXxBD7E6UxBhrMzXGA==}
peerDependencies:
@@ -1537,14 +1545,6 @@ packages:
- typescript
dev: true
/@capacitor/browser@5.0.6(@capacitor/core@5.5.1):
resolution: {integrity: sha512-wEI7Na6PVzSP/00ud7pjbBwXwVG7HywCdy2fJT/hzF6yuHn4tDirbOvbr1JKd9LZqKs2Xn+TapV38JhBRhX6YA==}
peerDependencies:
'@capacitor/core': ^5.0.0
dependencies:
'@capacitor/core': 5.5.1
dev: false
/@capacitor/cli@3.9.0:
resolution: {integrity: sha512-NkbVZhYb0oPdh/XArE2ZmOwPFJbla5meShGhv3DxKCXeKn1rt92ile+2xOgtB/j+mL7f9cqQzTQM/11sGQzMAg==}
engines: {node: '>=12.4.0'}

View File

@@ -121,15 +121,9 @@ function NwcDetails(props: {
}
}
function openInNostrClient() {
async function openInNostrClient() {
const uri = props.profile.nwc_uri;
openLinkProgrammatically(uri);
}
function openInPrimal() {
const uri = props.profile.nwc_uri;
const connectString = uri.replace("nostr+walletconnect", "primal");
openLinkProgrammatically(connectString);
await openLinkProgrammatically(uri);
}
return (
@@ -183,13 +177,9 @@ function NwcDetails(props: {
props.profile.tag !== "Subscription"
}
>
<Button layout="small" onClick={openInNostrClient}>
<Button layout="small" intent="blue" onClick={openInNostrClient}>
{i18n.t("settings.connections.open_in_nostr_client")}
</Button>
<Button layout="small" onClick={openInPrimal}>
{i18n.t("settings.connections.open_in_primal")}
</Button>
</Show>
<Button layout="small" onClick={confirmDelete}>
@@ -317,8 +307,8 @@ function Nwc() {
}
}
function openCallbackUri() {
openLinkProgrammatically(callbackUri());
async function openCallbackUri() {
await openLinkProgrammatically(callbackUri());
setSearchParams({ callbackUri: "" });
setCallbackDialogOpen(false);
}

View File

@@ -1,13 +1,19 @@
import { Browser } from "@capacitor/browser";
import { Capacitor } from "@capacitor/core";
import { AppLauncher } from '@capacitor/app-launcher';
// Safari is a jerk and is aggressive about blocking window.open calls if the logic is too complex
// Capacitor should be doing this for us but \o/
export function openLinkProgrammatically(href?: string) {
if (!href) return;
export async function openLinkProgrammatically(url?: string) {
if (!url) return;
if (Capacitor.isNativePlatform()) {
Browser.open({ url: href || "", windowName: "_blank" });
const { value } = await AppLauncher.canOpenUrl({ url });
if (!value) {
// Try to open in browser just in case that works glhf
window.open(url || "", "_blank");
return;
} else {
window.open(href || "", "_blank");
await AppLauncher.openUrl({ url});
}
} else {
window.open(url || "", "_blank");
}
}