header-bleepy-logo

DEVELOPERS

KO

settings

mainDescription

Android, IOS, Flutter, React Native mainDescription1


android

androidSubtitle

Interface function

Description

sharedInviteLink(inviteCode: String, infoMessage: String, link: String)
item1
kotlin
// 블리피 Launcher Web <-> App 인터페이스 규격 class ExampleWebAppInterface(private val mContext: Context) { ... @JavascriptInterface fun sharedInviteLink(inviteCode: String, infoMessage: String, link: String) { // 초대 미션 공유 val msg = "$infoMessage\n초대코드: $inviteCode\n\n$link" // Android Sharesheet를 통해 텍스트 콘텐츠를 공유합니다. val sendIntent: Intent = Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_TEXT, msg) type = "text/plain" } val shareIntent = Intent.createChooser(sendIntent, null) mContext.startActivity(shareIntent) } ... }

ios

iosSubtitle

iosStep1

iosStep1subtitle1

  • iosStep1subtitle1-1

swift
// ShareSheet.swift import SwiftUI import UIKit // postMessage로 넘어오는 문자열을 JSON 형태로 파싱하기 위해 선언 // inviteCode - 발급된 초대코드 // infoMessage - Client Admin에 입력된 안내 메세지 // link - Client Admin에 입력된 초대 링크 struct InviteLink: Codable { var inviteCode: String var infoMessage: String var link: String } // 공유하기 시트 struct ShareSheet: UIViewControllerRepresentable { var items: [Any] // 공유할 항목 func makeUIViewController(context: Context) -> UIActivityViewController { let controller = UIActivityViewController(activityItems: items, applicationActivities: nil) return controller } func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) { // 업데이트가 필요할 경우 여기에 로직 추가 } }

iosStep2

  • iosStep2-1

  • iosStep2-2

  • iosStep2-3

swift
// LauncherWebView.swift import WebKit import SwiftUI struct LauncherWebView: UIViewRepresentable { ... // 초대 링크 처리할 콜백 함수 let onSharedInviteLink: (String, String, String) -> Void class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler { ... func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { // 런처 친구초대 링크 공유 이벤트 수신 시 처리 if message.name == "sharedInviteLink" { // 메시지의 body는 JSON.stringify 문자열이라 디코딩 필요 if let jsonString = message.body as? String, let jsonData = jsonString.data(using: .utf8) { do { // JSON 문자열을 ShareSheet 클래스 내 InviteLink 구조체로 디코딩 let inviteData = try JSONDecoder().decode(InviteLink.self, from: jsonData) // 부모의 onSharedInviteLink 메서드 호출 parent.onSharedInviteLink(inviteData.inviteCode, inviteData.infoMessage, inviteData.link) } catch { print("Failed to decode JSON: (error.localizedDescription)") } } else { print("Failed to convert message body to String or Data") } } } ... } ... func makeUIView(context: Context) -> WKWebView { ... // javascript에서 전달하는 이벤트 등록 contentController.add(context.coordinator, name: "sharedInviteLink") ... } ... static func dismantleUIView(_ uiView: WKWebView, coordinator: Self.Coordinator) { uiView.configuration.userContentController.removeScriptMessageHandler(forName: "sharedInviteLink") } }

iosStep3

iosStep3subtitle

  • iosStep3-1

  • iosStep3-2

swift
// LauncherContentView.swift import SwiftUI import WebKit struct LauncherContentView: View { ... // ShareSheet를 표시할 때 사용할 상태 변수 @State private var isShowingShareSheet = false @State private var shareItems: [Any] = [] var body: some View { LauncherWebView( url: URL(string: "런처 URL"), // 친구 초대 링크 공유 이벤트 핸들링 처리 onSharedInviteLink: { inviteCode, infoMessage, link in // 공유할 항목 설정 shareItems = ["\(infoMessage)\n\n초대코드 : \(inviteCode)\n\n\(link)"] // ShareSheet를 표시하도록 상태를 변경 isShowingShareSheet = true }, ) .navigationBarBackButtonHidden(true) // ShareSheet를 표시하는 시트 추가 .sheet(isPresented: $isShowingShareSheet) { ShareSheet(items: shareItems) } } ... }

flutter

flutterTitle1

flutterTitle1Subtitle1

  • flutterTitle1list1

    • flutterTitle1list1-1
shell
flutter pub add share_plus

flutterTitle2

flutterTitle2Subtitle1

handlerName

Type

Description

BlpLauncher
sharedInviteLink
item1
dart
// lib/screens/bleepy_screen.dart InAppWebView( key: webViewKey, initialUrlRequest: URLRequest(url: WebUri(widget.launcherUrl)), initialSettings: options, onWebViewCreated: (controller) { webViewController = controller; // 자바스크립트 핸들러 추가 controller.addJavaScriptHandler(handlerName: 'BlpLauncher', callback: (message) { final data = jsonDecode(message[0]); final key = data['type']; switch (key) { ... // 추가 case "sharedInviteLink": sharedInviteLink(data["inviteCode"], data["infoMessage"], data["link"]); break; default: break; } }); } )

flutterTitle3

flutterTitle3Subtitle1

dart
// lib/screens/bleepy_screen.dart import 'package:share_plus/share_plus.dart'; // 친구초대 링크 공유하기 void sharedInviteLink(String infoMessage, String inviteCode, String link) async { try { // 메세지 예시 const msg = "$infoMessage\n초대코드 : $inviteCode\n\n$link" await Share.share(msg); } catch (error: any) { // Share API error } }

rn

rnSubtitle

Type

Description

sharedInviteLink
item1
typescript
// src/screens/launcher/Launcher.tsx import {WebView, WebViewMessageEvent} from 'react-native-webview'; export default function Launcher() { // WebView에서 보내온 메세지 처리 const onMessage = (e: WebViewMessageEvent) => { const {type, inviteCode, infoMessage, link} = JSON.parse(e.nativeEvent.data); switch (type) { ... // 추가 case 'sharedInviteLink': sharedInviteLink(inviteCode, infoMessage, link); break; } }; return ( <View> <WebView ... onMessage={onMessage} ... /> </View> ); } }

rnTitle1

rnSubtitle1

typescript
// src/screens/launcher/Launcher.tsx import { Share } from 'react-native'; // 친구초대 링크 공유하기 const sharedInviteLink = async (inviteCode: string, infoMessage: string, link: string) => { try { // 메세지 예시 const msg = '{infoMessage}\n초대코드 : {inviteCode}\n\n{link}' await Share.share({ message: msg, }); } catch (error: any) { // Share API error } };

footerTitle

"[Client Admin] footerMessage


v1.0.6