protocol_handler 패키지는 플러터 애플리케이션이 사용자 정의 URL 스키마를 등록하고 응답할 수 있도록 하여 다중 플랫폼 간 딥 링크를 가능하게 합니다. 이는 앱을 시작하고 URI를 통해 데이터를 전달함으로써 외부 링크(예: myapp://open)를 처리할 수 있게 해줍니다. 다른 앱, 웹 서비스 또는 시스템 레벨 트리거와의 통합에 특히 유용합니다. 이 플러그인은 Android, iOS, macOS 및 Windows를 지원하여 외부 소스에서의 원활한 탐색이 필요한 크로스플랫폼 데스크톱 및 모바일 앱에 적합합니다.
사용 사례
사용자 정의 URL 스키마 처리
이메일 또는 웹사이트에서 깊은 링크 활성화
제3자 앱과의 통합
데스크톱 및 모바일 워크플로우 지원
외부 링크에서 앱 실행
주요 기능
크로스 플랫폼 지원
사용자 정의 프로토콜 등록
URI 데이터 추출
간단한 API 통합
데스크톱 및 모바일 호환성
적합한 대상
딥 링크가 필요한 앱
데스크톱 및 모바일 하이브리드 앱
외부 서비스 통합
앱 간 통신
유니버설 링크를 구축하는 개발자
고려 사항
플랫폼별 설정이 필요합니다
iOS에서 추가 구성이 필요할 수 있습니다
지원되는 플랫폼에 제한됨
URI 처리와 관련된 보안 고려 사항
표준 HTTP URL에 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
🚀 Ship Your App Faster: Try Fastforge - The simplest way to build, package and distribute your Flutter apps.
protocol_handler
This plugin allows Flutter apps to register and handle custom protocols (i.e. deep linking).
Change the file android/app/src/main/AndroidManifest.xml as follows:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.leanflutter.plugins.protocol_handler_example">
<application
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="protocol_handler_example">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>+ <action android:name="android.intent.action.VIEW" />++ <category android:name="android.intent.category.DEFAULT" />+ <category android:name="android.intent.category.BROWSABLE" />+ <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->+ <data android:scheme="myprotocol" />+ </intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
import'package:protocol_handler/protocol_handler.dart';
voidmain() async {
// Must add this line.WidgetsFlutterBinding.ensureInitialized();
// Register a custom protocol// For macOS platform needs to declare the scheme in ios/Runner/Info.plistawait protocolHandler.register('myprotocol');
runApp(MyApp());
}