File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
pages/MemeDetailPage/components Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
22import { AnimatePresence } from 'motion/react' ;
33import { KakaoIcon , MoreInfo , LinkCopyIcon } from '@/assets/icons' ;
44import * as S from './MemeShareSheet.styles' ;
5+ import { nativeBridge } from '@/utils/bridge' ;
56
67interface MemeShareSheetProps {
78 isOpen : boolean ;
@@ -35,8 +36,12 @@ const MemeShareSheet = ({
3536
3637 const handleKakaoShare = ( ) => {
3738 if ( isWebview ) {
38- const kakaoShareUrl = `kakaolink://send?text=${ encodeURIComponent ( title ) } &image=${ encodeURIComponent ( imageUrl ) } &url=${ encodeURIComponent ( window . location . href ) } ` ;
39- window . location . href = kakaoShareUrl ;
39+ nativeBridge . shareKakao ( {
40+ title,
41+ image : imageUrl ,
42+ } ) ;
43+ // const kakaoShareUrl = `kakaolink://send?text=${encodeURIComponent(title)}&image=${encodeURIComponent(imageUrl)}&url=${encodeURIComponent(window.location.href)}`;
44+ // window.location.href = kakaoShareUrl;
4045 return ;
4146 }
4247
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export const COMMAND_TYPE = {
44 WEB_ENTERED : 'WEB_ENTERED' ,
55 APP_ENTERED : 'APP_ENTERED' ,
66 SHOW_MORE_MEMES : 'SHOW_MORE_MEMES' ,
7+ SHARE_KAKAO : 'SHARE_KAKAO' ,
78} as const ;
89
910export type CommandType = ( typeof COMMAND_TYPE ) [ keyof typeof COMMAND_TYPE ] ;
@@ -18,12 +19,18 @@ export interface CustomMemeData {
1819 image : string ;
1920}
2021
22+ export interface ShareKakaoData {
23+ title : string ;
24+ image : string ;
25+ }
26+
2127export type CommandDataMap = {
2228 [ COMMAND_TYPE . SHARE_MEME ] : ShareMemeData ;
2329 [ COMMAND_TYPE . CUSTOM_MEME ] : CustomMemeData ;
2430 [ COMMAND_TYPE . WEB_ENTERED ] : null ;
2531 [ COMMAND_TYPE . APP_ENTERED ] : null ;
2632 [ COMMAND_TYPE . SHOW_MORE_MEMES ] : null ;
33+ [ COMMAND_TYPE . SHARE_KAKAO ] : ShareKakaoData ;
2734} ;
2835
2936export interface BridgeCommand < T extends CommandType > {
Original file line number Diff line number Diff line change 44 CommandDataMap ,
55 CommandType ,
66 CustomMemeData ,
7+ ShareKakaoData ,
78 ShareMemeData ,
89} from '../types/bridge' ;
910
@@ -80,6 +81,11 @@ class NativeBridge {
8081 showMoreMemes ( ) {
8182 this . sendCommand ( COMMAND_TYPE . SHOW_MORE_MEMES ) ;
8283 }
84+
85+ // 카카오 공유
86+ shareKakao ( data : ShareKakaoData ) {
87+ this . sendCommand ( COMMAND_TYPE . SHARE_KAKAO , data ) ;
88+ }
8389}
8490
8591export const nativeBridge = NativeBridge . getInstance ( ) ;
You can’t perform that action at this time.
0 commit comments