Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

docs.flutter.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.

Learn more

Flutter 3.41 is live! Check out theFlutter 3.41 blog post!

Set up universal links for iOS

Learn how to set up universal links for an iOS application built with Flutter.

Deep linking allows an app user to launch an app with a URI. This URI contains scheme, host, and path, and opens the app to a specific screen.

Auniversal link, a type of deep link exclusive to iOS devices, uses only thehttp orhttps protocols.

To set up universal links, you need to own a web domain. As a temporary solution, consider usingFirebase Hosting orGitHub Pages.

Once you've set up your deep links, you can validate them. To learn more, seeValidate deep links.

Create or modify a Flutter app

#

Write a Flutter app that can handle an incoming URL.

This example uses thego_router package to handle the routing. The Flutter team maintains thego_router package. It provides a simple API to handle complex routing scenarios.

  1. To create a new application, typeflutter create <app-name>.

    flutter create deeplink_cookbook
  2. To include thego_router package as a dependency, runflutter pub add:

    flutter pub add go_router
  3. To handle the routing, create aGoRouter object in themain.dart file:

    main.dart
    dart
    import'package:flutter/material.dart';import'package:go_router/go_router.dart';voidmain()=>runApp(MaterialApp.router(routerConfig:router));/// This handles '/' and '/details'.finalrouter=GoRouter(routes:[GoRoute(path:'/',builder:(_,_)=>Scaffold(appBar:AppBar(title:constText('Home Screen')),),routes:[GoRoute(path:'details',builder:(_,_)=>Scaffold(appBar:AppBar(title:constText('Details Screen')),),),],),],);

Adjust iOS build settings

#
  1. Launch Xcode.

  2. Open theios/Runner.xcworkspace file inside the Flutter project'sios folder.

    Version note

    If you use a Flutter version earlier than 3.27, you need to manually opt in to deep linking by adding the key and value pairFlutterDeepLinkingEnabled andYES toinfo.Plist.

    Note

    If you're using third-party plugins to handle deep links, such asapp_links, Flutter's default deeplink handler will break these plugins.

    If you use a third-party plugin, add the key and value pairFlutterDeepLinkingEnabled andNO toinfo.Plist.

Add associated domains

#
Warning

Personal development teams don't support the Associated Domains capability. To add associated domains, choose the IDE tab.

  1. Launch Xcode if necessary.

  2. Click the top-levelRunner.

  3. In the Editor, click theRunner target.

  4. ClickSigning & Capabilities.

  5. To add a new domain, click+ Capability underSigning & Capabilities.

  6. ClickAssociated Domains.

    Xcode associated domains screenshot

  7. In theAssociated Domains section, click+.

  8. Enterapplinks:<web domain>. Replace<web domain> with your own domain name.

    Xcode add associated domains screenshot

  1. Open theios/Runner/Runner.entitlements XML file in your preferred editor.

  2. Add an associated domain inside the<dict> tag.

    xml
    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.developer.associated-domains</key><array><string>applinks:example.com</string></array></dict></plist>
  3. Save theios/Runner/Runner.entitlements file.

To check that the associated domains you created are available, perform the following steps:

  1. Launch Xcode if necessary.

  2. Click the top-levelRunner.

  3. In the Editor, click theRunner target.

  4. ClickSigning & Capabilities. The domains should appear in theAssociated Domains section.

    Xcode add associated domains screenshot

You have finished configuring the application for deep linking.

Associate your app with your web domain

#

You need to host anapple-app-site-association file in the web domain. This file tells the mobile browser which iOS application to open instead of the browser. To create the file, find theappID of the Flutter app you created in the previous section.

Locate components of theappID

#

Apple formats theappID as<team id>.<bundle id>.

  • Locate the bundle ID in the Xcode project.
  • Locate the team ID in thedeveloper account.

For example: Given a team ID ofS8QB4VV633 and a bundle ID ofcom.example.deeplinkCookbook, you would enter anappID entry ofS8QB4VV633.com.example.deeplinkCookbook.

Create and hostapple-app-site-association JSON file

#

This file uses the JSON format. Don't include the.json file extension when you save this file. PerApple's documentation, this file should resemble the following content:

json
{"applinks":{"apps":[],"details":[{"appIDs":["S8QB4VV633.com.example.deeplinkCookbook"],"paths":["*"],"components":[{"/":"/*"}]}]},"webcredentials":{"apps":["S8QB4VV633.com.example.deeplinkCookbook"]}}
  1. Set one value in theappIDs array to<team id>.<bundle id>.

  2. Set thepaths array to["*"]. Thepaths array specifies the allowed universal links. Using the asterisk,* redirects every path to the Flutter app. If needed, change thepaths array value to a setting more appropriate to your app.

  3. Host the file at a URL that resembles the following structure.

    <webdomain>/.well-known/apple-app-site-association

  4. Verify that your browser can access this file.

Note

If you have more than one scheme/flavor, you can add more than oneappID into theappIDs field.

Test a universal link using a physical iOS device or the Simulator.

Note

It might take up to 24 hours before Apple'sContent Delivery Network (CDN) requests theapple-app-site-association (AASA) file from your web domain. Until the CDN requests the file, the universal link won't work. To bypass Apple's CDN, check out thealternate mode section.

  1. Before testing, install the Flutter app on the iOS device or Simulator, Useflutter run on the desired device.

    Simulator screenshot

    When complete, the Flutter app displays on the home screen of the iOS device or Simulator.

  2. If you test using the Simulator, use the Xcode CLI:

    xcrun simctl openurl booted https://<web domain>/details
  3. If you test with a physical iOS device:

    1. Launch theNote app.
    2. Type the URL in theNote app.
    3. Click the resulting link.

    If successful, the Flutter app launches and displays its details screen.

    Deeplinked Simulator screenshot

Find the source code

#

You can find the source code for thedeeplink_cookbook recipe in the GitHub repo.

Was this page's content helpful?

Unless stated otherwise, the documentation on this site reflects Flutter 3.38.6. Page last updated on 2025-10-28.View source orreport an issue.


[8]ページ先頭

©2009-2026 Movatter.jp