File tree Expand file tree Collapse file tree 2 files changed +36
-7
lines changed
Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change 11import React , { useEffect , useRef } from 'react' ;
22import { createPortal } from 'react-dom' ;
3- import { toast } from 'sonner' ;
43import type { Position , Webcam } from '@/entities/slop/model/model' ;
54import ArrowRightIcon from '@/shared/icons/arrow-right' ;
6- import NeutralFace from '@/shared/icons/neutral-face' ;
75import { cn } from '@/shared/lib' ;
6+ import postAppMessage from '@/shared/lib/postAppMessage' ;
87import CameraButton from '@/shared/ui/cam-button' ;
98import { Tooltip } from '@/shared/ui/tooltip' ;
109import useSlopStore from '../hooks/useSlopStore' ;
@@ -45,11 +44,7 @@ const SlopCamera = ({
4544 setOpenCamera ( ) ;
4645
4746 if ( ! src ) {
48- toast (
49- < >
50- < NeutralFace /> 선택한 웹캠은 아직 준비중 이에요
51- </ >
52- ) ;
47+ postAppMessage ( '선택한 웹캠은 아직 준비중 이에요' ) ;
5348 }
5449 } ;
5550
Original file line number Diff line number Diff line change 1+ declare global {
2+ interface Window {
3+ BRIDGE : {
4+ sendMessage : ( message : string ) => void ;
5+ } ;
6+ webkit : {
7+ messageHandlers : {
8+ weski : {
9+ showToast : ( message : string ) => void ;
10+ } ;
11+ } ;
12+ } ;
13+ }
14+ }
15+
16+ const postAppMessage = ( message : string ) => {
17+ const userAgent = navigator . userAgent ;
18+ const android = userAgent . match ( / A n d r o i d / i) ;
19+ const iphone = userAgent . match ( / i P h o n e / i) ;
20+
21+ if ( android !== null ) {
22+ console . log ( "Android" ) ;
23+ return window . BRIDGE . sendMessage ( message ) ;
24+
25+ } else if ( iphone !== null ) {
26+ console . log ( "iOS" ) ;
27+ return window . webkit . messageHandlers . weski . showToast ( message ) ;
28+
29+ } else {
30+ return window . opener . postMessage ( message ) ;
31+ }
32+ }
33+
34+ export default postAppMessage ;
You can’t perform that action at this time.
0 commit comments