Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mobile apps to provide QR code functionality #19570

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/external_app/external_messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ interface EMOutgoingMessageConfigGet extends EMMessage {
type: "config/get";
}

interface EMOutgoingMessageScanQRCode extends EMMessage {
type: "qr_code/scan";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also tell the app what kind of QR codes we want to scan, what to accept, or does the app give the frontend everything it finds, and we tell it if that is something we accept/scan, so if we are done and it can remove the scanner?

I'm thinking about 2 QR codes side by side on a package, you dont want the app to give the wrong code to the frontend.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can start with accepting everything. We can expand it later to limit the things it accept. I would love for the frontend to get a generic QR code scanner that could work with a new concept of QR discovery for manifest.json.

title: string;
description: string;
alternative_option_label?: string;
}

interface EMOutgoingMessageMatterCommission extends EMMessage {
type: "matter/commission";
}
Expand All @@ -48,6 +55,13 @@ type EMOutgoingMessageWithAnswer = {
request: EMOutgoingMessageConfigGet;
response: ExternalConfig;
};
"qr_code/scan": {
request: EMOutgoingMessageScanQRCode;
response:
| EMIncomingMessageQRCodeResponseCanceled
| EMIncomingMessageQRCodeResponseAlternativeOptions
| EMIncomingMessageQRCodeResponseScanResult;
};
};

interface EMOutgoingMessageExoplayerPlayHLS extends EMMessage {
Expand Down Expand Up @@ -158,6 +172,19 @@ interface EMIncomingMessageShowAutomationEditor {
};
}

export interface EMIncomingMessageQRCodeResponseCanceled {
action: "canceled";
}

export interface EMIncomingMessageQRCodeResponseAlternativeOptions {
action: "alternative_options";
}

export interface EMIncomingMessageQRCodeResponseScanResult {
action: "scan_result";
result: string;
}

export type EMIncomingMessageCommands =
| EMIncomingMessageRestart
| EMIncomingMessageShowNotifications
Expand All @@ -180,6 +207,7 @@ export interface ExternalConfig {
canCommissionMatter: boolean;
canImportThreadCredentials: boolean;
hasAssist: boolean;
hasQRScanner: number;
}

export class ExternalMessaging {
Expand Down
Loading