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

套件詳情v2.0.2

whatsapp_share

在您的 Flutter 應用中,透過 WhatsApp 與特定聯絡人分享訊息、連結或檔案的簡單方式。

Android
近 30 天下載
131
喜歡數
40
Pub 分數
160

安裝套件

flutter pub add whatsapp_share

套件介紹

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

一個輕量級的 Flutter 套件,可在 Android 上透過 WhatsApp 直接將訊息、連結或檔案分享給特定聯絡人。它簡化了開啟 WhatsApp 並預填內容與目標聯絡人號碼的過程,透過無縫通訊提升使用者參與度。此套件利用 Android 意圖實現原生整合,確保可靠傳遞且設定簡單。非常適合希望藉由直接訊息功能提升使用者觸及度的應用。

適用情境

  • 分享推薦連結
  • 發送支援訊息
  • 分發促銷內容
  • 引導用戶聯繫客服
  • 自動化追蹤訊息
  • 共享媒體檔案

主要特色

  • 與 Android 意圖的輕鬆整合
  • 支援文字、連結和檔案
  • 針對特定的 WhatsApp 聯繫人
  • 最小配置要求
  • 依賴原生 WhatsApp 功能
  • 初始設定後可離線使用

適合對象

  • 需要直接訪問 WhatsApp 聯繫人的應用
  • 客戶支援功能
  • 行銷與推薦系統
  • 內容分發工具
  • 使用者入門流程

使用建議

  • 僅限 Android 平台支援
  • 需要在設備上安裝 WhatsApp
  • 僅限聯絡人分享
  • 無 iOS 相容性
  • 依賴系統級權限
  • 可能需要使用者確認才能分享

原始 README

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

Whatsapp Share Plugin

pub package

A Flutter plugin for Android providing a simple way to share a message, link or local files to specific WhatsApp contact.

Features:

  • Share messages or link urls to specific contact.
  • Share local files to specific contact.

Installation

First, add this to your package's pubspec.yaml file:

dependencies:
  whatsapp_share: ^1.1.1

Now in your Dart code, you can use:

import 'package:whatsapp_share/whatsapp_share.dart';

Installation (Platform Specific)

iOS

Add if not exists one row to the ios/podfile after target runner:

...

target 'Runner' do
    use_frameworks!

...
Android

If you pretends to use the file share, you need to configure the file provider, this will give access to the files turning possible to share with other applications.

Add to AndroidManifest.xml:

<application>
...
<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>
</application>

Obs: You can change the android:name if you have an extension of file provider.

Add res/xml/provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

If you want to learn more about file provider you can access:

  • https://developer.android.com/reference/android/support/v4/content/FileProvider

How to use?

Here is an snippets app displaying the two whatsapp share methods .

Whatsapp installed in this device ?
 Future<void> isInstalled() async {
    final val = await WhatsappShare.isInstalled(
      package: Package.businessWhatsapp
    );
    print('Whatsapp Business is installed: $val');
  }

If whatsapp is not installed, please do not call WhatsappShare.share() and WhatsappShare.shareFile()

Share text, links

 Future<void> share() async {
    await WhatsappShare.share(
      text: 'Whatsapp share text',
      linkUrl: 'https://flutter.dev/',
      phone: '911234567890',
    );
  }

Share images, files

_image1.path contains path of the file which is shared to the whatsapp.


 Future<void> shareFile() async {
    await WhatsappShare.shareFile(
      phone: '911234567890',
      filePath: [_image1.path, _image2.path],
    );
  }

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。