fix(ios): resolve clipboard and notification issues in ContactQRScanFullView
- Replace useClipboard() with ClipboardService for iOS compatibility - Fix notification helper initialization timing issue - Add proper error handling for clipboard operations - Ensure consistent behavior across all platforms Fixes clipboard copy functionality on iOS builds where QR code clicks failed to copy content and showed notification errors. The ClipboardService provides platform-specific handling using Capacitor's clipboard plugin, while moving notification initialization to created() lifecycle hook prevents undefined function errors. Resolves: iOS clipboard copy failure and notification system errors
This commit is contained in:
@@ -104,7 +104,6 @@ import { Buffer } from "buffer/";
|
|||||||
import QRCodeVue3 from "qr-code-generator-vue3";
|
import QRCodeVue3 from "qr-code-generator-vue3";
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router } from "vue-router";
|
import { Router } from "vue-router";
|
||||||
import { useClipboard } from "@vueuse/core";
|
|
||||||
|
|
||||||
import { logger } from "../utils/logger";
|
import { logger } from "../utils/logger";
|
||||||
import { QRScannerFactory } from "../services/QRScanner/QRScannerFactory";
|
import { QRScannerFactory } from "../services/QRScanner/QRScannerFactory";
|
||||||
@@ -196,7 +195,7 @@ export default class ContactQRScanFull extends Vue {
|
|||||||
$router!: Router;
|
$router!: Router;
|
||||||
|
|
||||||
// Notification helper system
|
// Notification helper system
|
||||||
private notify = createNotifyHelpers(this.$notify);
|
private notify!: ReturnType<typeof createNotifyHelpers>;
|
||||||
|
|
||||||
isScanning = false;
|
isScanning = false;
|
||||||
error: string | null = null;
|
error: string | null = null;
|
||||||
@@ -264,6 +263,9 @@ export default class ContactQRScanFull extends Vue {
|
|||||||
* Loads user settings and generates QR code for contact sharing
|
* Loads user settings and generates QR code for contact sharing
|
||||||
*/
|
*/
|
||||||
async created() {
|
async created() {
|
||||||
|
// Initialize notification helper system
|
||||||
|
this.notify = createNotifyHelpers(this.$notify);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const settings = await this.$accountSettings();
|
const settings = await this.$accountSettings();
|
||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
@@ -646,36 +648,53 @@ export default class ContactQRScanFull extends Vue {
|
|||||||
* Copies contact URL to clipboard for sharing
|
* Copies contact URL to clipboard for sharing
|
||||||
*/
|
*/
|
||||||
async onCopyUrlToClipboard() {
|
async onCopyUrlToClipboard() {
|
||||||
const account = (await libsUtil.retrieveFullyDecryptedAccount(
|
try {
|
||||||
this.activeDid,
|
const account = (await libsUtil.retrieveFullyDecryptedAccount(
|
||||||
)) as Account;
|
this.activeDid,
|
||||||
const jwtUrl = await generateEndorserJwtUrlForAccount(
|
)) as Account;
|
||||||
account,
|
const jwtUrl = await generateEndorserJwtUrlForAccount(
|
||||||
this.isRegistered,
|
account,
|
||||||
this.givenName,
|
this.isRegistered,
|
||||||
this.profileImageUrl,
|
this.givenName,
|
||||||
true,
|
this.profileImageUrl,
|
||||||
);
|
true,
|
||||||
useClipboard()
|
);
|
||||||
.copy(jwtUrl)
|
|
||||||
.then(() => {
|
// Use the platform-specific ClipboardService for reliable iOS support
|
||||||
this.notify.toast(
|
const { copyToClipboard } = await import("../services/ClipboardService");
|
||||||
NOTIFY_QR_URL_COPIED.title,
|
await copyToClipboard(jwtUrl);
|
||||||
NOTIFY_QR_URL_COPIED.message,
|
|
||||||
QR_TIMEOUT_MEDIUM,
|
this.notify.toast(
|
||||||
);
|
NOTIFY_QR_URL_COPIED.title,
|
||||||
|
NOTIFY_QR_URL_COPIED.message,
|
||||||
|
QR_TIMEOUT_MEDIUM,
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error copying URL to clipboard:", {
|
||||||
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
|
this.notify.error("Failed to copy URL to clipboard.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies DID to clipboard for manual sharing
|
* Copies DID to clipboard for manual sharing
|
||||||
*/
|
*/
|
||||||
onCopyDidToClipboard() {
|
async onCopyDidToClipboard() {
|
||||||
useClipboard()
|
try {
|
||||||
.copy(this.activeDid)
|
// Use the platform-specific ClipboardService for reliable iOS support
|
||||||
.then(() => {
|
const { copyToClipboard } = await import("../services/ClipboardService");
|
||||||
this.notify.info(NOTIFY_QR_DID_COPIED.message, QR_TIMEOUT_LONG);
|
await copyToClipboard(this.activeDid);
|
||||||
|
|
||||||
|
this.notify.info(NOTIFY_QR_DID_COPIED.message, QR_TIMEOUT_LONG);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error copying DID to clipboard:", {
|
||||||
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
|
this.notify.error("Failed to copy DID to clipboard.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user