搜尋套件、儲存庫與 APP 分類

套件詳情v4.0.4

external_app_launcher

一個 Flutter 外掛程式,可協助您從您的應用程式開啟另一個應用程式

AndroidiOS
近 30 天下載
8.7萬
喜歡數
372
Pub 分數
150

安裝套件

flutter pub add external_app_launcher

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

external_app_launcher 套件是一個 Flutter 插件,可讓應用程式在 Android 與 iOS 裝置上開啟其他已安裝的應用程式。它透過套件名稱或 URL 簡化啟動外部應用程式,支援深度連結與特定應用意圖。這在整合地圖、訊息傳遞或社交平台等原生應用時特別實用。此套件可在兩大主要行動平台順暢運作,非常適合用於分享內容或將使用者導向第三方服務。設定需求極少,並提供可靠的跨平台功能。

適用情境

  • 從位置資料開啟地圖應用程式
  • 重定向使用者到訊息應用
  • 啟動社交媒體應用程式以分享
  • 與支付或電子郵件應用整合
  • 啟用指向特定應用螢幕的深度連結

主要特色

  • 支援 Android 和 iOS 平台
  • 用於啟動外部應用程式的簡單 API
  • 處理套件名稱和URL
  • 啟用深度連結
  • 跨平台相容性

適合對象

  • 需要應用重定向的應用
  • 共享或整合功能
  • 導航至第三方服務
  • 開發實用工具的開發者
  • 需要意圖處理的項目

使用建議

  • 需要正確的套件名稱或URL
  • 如果目標應用未安裝,可能會失敗
  • 對啟動的應用程式行為控制有限
  • 某些設備可能需要權限
  • 依賴於平台特定的實作

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Overview

A Flutter plugin which helps you to open another app from your app. The package asks you for four parameters out of which two are mandatory.

Getting Started

1. Add package to your project

Complete description to add this package to your project can be found here.

2. To setup native performance for the application in order to launch external apps

For opening apps in android

For opening an external app from your app in android, you need provide packageName of the app.

If the plugin finds the app in the device, it will be launched. But if the app is not installed in the device then it leads the user to playstore link of the app.

⚠️ Android 11+ Package Visibility (Required)

On Android 11 (API 30) and above, the OS restricts which packages your app can query. If you do not declare the target package in your AndroidManifest.xml, both isAppInstalled() and openApp() will silently behave as if the app is not installed — even if it is.

You must add a <queries> block above the <application> tag in your android/app/src/main/AndroidManifest.xml for every package you want to interact with:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <queries>
        <!-- Declare every package you want to check or launch -->
        <package android:name="net.pulsesecure.pulsesecure" />
        <package android:name="us.zoom.videomeetings" />
        <package android:name="com.instagram.android" />
        <!-- Add more packages as needed -->
    </queries>

    <application ...>
        ...
    </application>

</manifest>

Note: Without this declaration, isAppInstalled('us.zoom.videomeetings') will always return false on Android 11+ even if Zoom is installed.

Tip: If you want to query all apps (not recommended for privacy), you can use the QUERY_ALL_PACKAGES permission instead, but this requires justification when publishing to the Play Store.

⚠️ Android 10+ Background Activity Start Limits

On Android 10 (API 29) and above, the OS restricts apps from starting activities from the background (e.g. from background services, background broadcast receivers, or background notifications). Attempting to do so will result in a SecurityException being caught and a descriptive error message being returned.

If you need to launch external apps from background states, please review Android's guide on allowed exceptions for background starts.

Demo

In iOS, for opening an external app from your app, you need to provide the URL scheme of the target app.

⚠️ iOS Platform Limitation: URL Schemes Required

Due to iOS security sandboxing, it is impossible to launch or query external apps using package names/bundle IDs or without a registered custom URL scheme (e.g., instagram://).

  • You must obtain the target app's custom URL scheme.
  • If your app's deployment target is iOS 9 or above, you must also whitelist the scheme in your Info.plist under LSApplicationQueriesSchemes (see below).

To know more about URLScheme refer to this Link

Alternatively, you can launch Safari directly to open a website by calling:

await LaunchApp.openSafari(url: 'https://www.apple.com');

Or by passing the web URL directly to the iosUrlScheme parameter in openApp.

To open a URL in Google Chrome on both platforms:

await LaunchApp.openUrlInChrome(url: 'https://www.example.com');

On Android this targets the com.android.chrome package. On iOS it converts https:// → googlechromes://.

To target any specific browser on Android, or use a custom iOS scheme:

await LaunchApp.openUrlInBrowser(
  url: 'https://www.example.com',
  androidBrowserPackage: 'org.mozilla.firefox', // Firefox on Android
  iosUrlScheme: 'firefox://open-url?url=https://www.example.com', // Firefox on iOS
);

If the specified browser is not installed on Android, the system default browser is used as fallback.

If your deployment target is greater than or equal to 9, then you also need to update external app information in Info.plist.

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>pulsesecure</string> // url scheme name of the app
</array>

But unlike in Android, it will not navigate to store (appStore) if app is not found in the device.

For doing so you need to provide the iTunes link of the app.

Demo

Implementation

Apart from opening an external app, this package can also be used to check whether an app is installed in the device or not.

This can done by simply calling the function isAppInstalled

await LaunchApp.isAppInstalled(
  androidPackageName: 'net.pulsesecure.pulsesecure'
  iosUrlScheme: 'pulsesecure://'
);

This returns true and false based on the fact whether app is installed or not.

Code Illustration

import 'package:flutter/material.dart';
import 'package:external_app_launcher/external_app_launcher.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Color containerColor = Colors.red;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Container(
            height: 50,
            width: 150,
            child: RaisedButton(
              color: Colors.blue,
              onPressed: () async {
                await LaunchApp.openApp(
                  androidPackageName: 'net.pulsesecure.pulsesecure',
                  iosUrlScheme: 'pulsesecure://',
                  appStoreLink: 'itms-apps://itunes.apple.com/us/app/pulse-secure/id945832041',
                  // openStore: false
                );

                // Enter the package name of the App you want to open and for iOS add the URLscheme to the Info.plist file.
                // The `openStore` argument decides whether the app redirects to PlayStore or AppStore.
                // For testing purpose you can enter com.instagram.android
              },
              child: Container(
                child: Center(
                  child: Text("Open",
                    textAlign: TextAlign.center,
                  ),
                ))),
          ),
        ),
      ),
    );
  }
}

所屬分類

原始碼儲存庫

使用此套件的專案