Scan Contact Info
-
-
- If you do not see a scanning camera window here, check your camera
- permissions.
-
+
+
+
+
+
+
+ If you do not see the camera, check your camera permissions.
+
+
@@ -91,8 +104,8 @@ import { AxiosError } from "axios";
import QRCodeVue3 from "qr-code-generator-vue3";
import { Component, Vue } from "vue-facing-decorator";
import { QrcodeStream } from "vue-qrcode-reader";
-import { useClipboard } from "@vueuse/core";
-
+import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
+import { PlatformService } from "../services/PlatformService";
import QuickNav from "../components/QuickNav.vue";
import UserNameDialog from "../components/UserNameDialog.vue";
import { NotificationIface } from "../constants/app";
@@ -110,9 +123,15 @@ import { decodeEndorserJwt, ETHR_DID_PREFIX } from "../libs/crypto/vc";
import { retrieveAccountMetadata } from "../libs/util";
import { Router } from "vue-router";
import { logger } from "../utils/logger";
+import { Camera, CameraResultType, CameraSource } from "@capacitor/camera";
+
+// Declare global constants
+declare const __USE_QR_READER__: boolean;
+declare const __IS_MOBILE__: boolean;
+
@Component({
components: {
- QrcodeStream,
+ QrcodeStream: __USE_QR_READER__ ? QrcodeStream : null,
QRCodeVue3,
QuickNav,
UserNameDialog,
@@ -121,6 +140,11 @@ import { logger } from "../utils/logger";
export default class ContactQRScanShow extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
$router!: Router;
+ declare $refs: {
+ userNameDialog: {
+ open: (callback: (name: string) => void) => void;
+ };
+ };
activeDid = "";
apiServer = "";
@@ -131,6 +155,9 @@ export default class ContactQRScanShow extends Vue {
ETHR_DID_PREFIX = ETHR_DID_PREFIX;
+ private platformService: PlatformService =
+ PlatformServiceFactory.getInstance();
+
async created() {
const settings = await retrieveSettingsForActiveAccount();
this.activeDid = settings.activeDid || "";
@@ -144,19 +171,149 @@ export default class ContactQRScanShow extends Vue {
if (account) {
const name =
(settings.firstName || "") +
- (settings.lastName ? ` ${settings.lastName}` : ""); // lastName is deprecated, pre v 0.1.3
+ (settings.lastName ? ` ${settings.lastName}` : "");
this.qrValue = await generateEndorserJwtUrlForAccount(
account,
!!settings.isRegistered,
name,
- settings.profileImageUrl,
+ settings.profileImageUrl || "",
false,
);
}
+
+ // Initialize camera with retry logic
+ if (this.useQRReader) {
+ await this.initializeCamera();
+ }
+ }
+
+ async initializeCamera(retryCount = 0): Promise