zipup_partners 0.0.8
zipup_partners: ^0.0.8 copied to clipboard
Flutter plugin that provides a WebView-based SDK using a native Android AAR and iOS XCFramework, with real-time message and event communication between WebView and Flutter.
zipup_partners #
Zipup SDK를 Flutter에서 사용할 수 있도록 하는 플러그인입니다.
기능 #
- Android 및 iOS 네이티브 SDK 통합
- SDK 초기화 및 실행
- 이벤트 스트림을 통한 실시간 이벤트 수신
- MethodChannel 및 EventChannel을 통한 플랫폼 간 통신
설치 #
pubspec.yaml 파일에 다음을 추가하세요:
dependencies:
zipup_partners:
git:
url: https://github.com/your-repo/zipup_sdk_flutter.git
# 또는 로컬 경로 사용:
# path: ../zipup_sdk_flutter
그 다음 다음 명령어를 실행하세요:
flutter pub get
iOS 설정 #
iOS 프로젝트의 Podfile이 있는 디렉토리에서:
cd ios
pod install
사용법 #
1. SDK 초기화 #
import 'package:zipup_partners/zipup_sdk_flutter.dart';
final zipupSdk = ZipupSdkFlutter();
// SDK 초기화
await zipupSdk.initSdk('your_client_id', 'your_client_secret');
2. SDK 실행 #
// Zipup SDK 화면 열기
await zipupSdk.viewZipupSDK();
3. 이벤트 수신 #
// 이벤트 스트림 구독
final eventSubscription = zipupSdk.getEventStream()?.listen(
(event) {
final eventName = event['event'] as String?;
final eventData = event['data'] as String?;
print('Received event: $eventName, data: $eventData');
if (eventName == 'close') {
// SDK가 닫힐 때 처리
print('SDK closed');
}
},
onError: (error) {
print('Event error: $error');
},
);
// 사용 후 구독 취소
eventSubscription?.cancel();
4. SDK 닫기 #
await zipupSdk.close();
완전한 예제 #
import 'package:flutter/material.dart';
import 'package:zipup_partners/zipup_sdk_flutter.dart';
import 'dart:async';
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _zipupSdk = ZipupSdkFlutter();
StreamSubscription<Map<String, dynamic>>? _eventSubscription;
@override
void initState() {
super.initState();
_setupEventListener();
}
void _setupEventListener() {
_eventSubscription = _zipupSdk.getEventStream()?.listen(
(event) {
final eventName = event['event'] as String?;
if (eventName == 'close') {
print('SDK closed');
}
},
);
}
Future<void> _initSdk() async {
await _zipupSdk.initSdk('your_client_id', 'your_client_secret');
}
Future<void> _viewSdk() async {
await _zipupSdk.viewZipupSDK();
}
@override
void dispose() {
_eventSubscription?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Zipup SDK Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: _initSdk,
child: Text('Initialize SDK'),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: _viewSdk,
child: Text('View Zipup SDK'),
),
],
),
),
),
);
}
}
API 참조 #
ZipupSdkFlutter #
Methods
-
Future<String?> initSdk(String clientId, String clientSecret)- SDK를 초기화합니다.
clientId: 클라이언트 IDclientSecret: 클라이언트 시크릿
-
Future<String?> viewZipupSDK()- Zipup SDK 화면을 엽니다.
-
Future<String?> close()- SDK를 닫습니다.
-
Stream<Map<String, dynamic>>? getEventStream()- SDK 이벤트 스트림을 반환합니다.
- 이벤트 형식:
{'event': 'event_name', 'data': 'event_data'}
-
Future<String?> addListener(String eventName)- 이벤트 리스너를 추가합니다. (권장:
getEventStream()사용)
- 이벤트 리스너를 추가합니다. (권장:
-
Future<String?> removeListeners(int count)- 이벤트 리스너를 제거합니다. (권장: Stream 구독 취소)
요구사항 #
- Flutter >= 3.3.0
- Dart >= 3.11.0
- iOS >= 13.0
- Android: 최소 SDK 버전은 네이티브 SDK 요구사항에 따릅니다.
라이선스 #
이 프로젝트의 라이선스는 LICENSE 파일을 참조하세요.
지원 #
문제가 발생하거나 질문이 있으시면 이슈를 등록해주세요.