Flutter에서 Deep Link를 사용하기 위해서는 하기의 uni_links 라이브러리를 사용 한다.
https://pub.dev/packages/uni_links
uni_links | Flutter Package
Flutter plugin for accepting incoming links - App/Deep Links (Android), Universal Links and Custom URL schemes (iOS).
pub.dev
기본 설정
1. Android ( AndroidMenifest.xml )
<intent-filter>
<action android:name=”android.intent.action.VIEW” />
<category android:name=”android.intent.category.DEFAULT” />
<category android:name=”android.intent.category.BROWSABLE” />
<data
android:host=”flutter.deeplink.sample”
android:pathPrefix=”/”
android:scheme=”https” />
</intent-filter>
2. iOS (Info.plist)
<?xml>
<plist>
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>flutter.deeplink.sample</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
</array>
</dict>
</plist>
3. Deep Link를 사용하는 페이지에서 초기화
Future<String> initialLink() async {
try {
final initialLink = await getInitialLink();
return initialLink;
} on PlatformException catch (exception){
log(exception.message);
}
}
String deepLinkURL = “”;
@override
void initState() {
initialLink().then((value) => this.setState(() {
deepLinkURL = value;
}));
super.initState();
}
위와 같이 설정하면 flutter.deeplink.sample 로 들어오는 것은 설정된 페이지를 뜨게 해줍니다.
'Flutter(플러터) > UI' 카테고리의 다른 글
Flutter IconButton 패딩 ( Padding ) 제거 (0) | 2022.01.10 |
---|---|
Flutter MainAxisSize min ? max ? (0) | 2022.01.06 |
Flutter onResume() , onPause() 있다? (0) | 2022.01.06 |
Flutter 아이콘 ( Icon ) 만들기 (0) | 2022.01.06 |
Flutter Animation icon (0) | 2022.01.06 |
댓글