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

onesignal_flutter 封面
套件詳情v5.7.2

onesignal_flutter

OneSignal 是一款免費的行動應用程式推播通知服務。此外掛程式可輕鬆將您的 Flutter 應用程式與 OneSignal 整合。

AndroidiOS
近 30 天下載
18.1萬
喜歡數
955
Pub 分數
125

安裝套件

flutter pub add onesignal_flutter

套件介紹

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

onesignal_flutter 套件讓 Flutter 應用程式能夠整合 OneSignal,這是一款免費的行動應用程式推播通知服務。它簡化了在 Android 與 iOS 平台上發送與接收推播通知的流程。開發者可輕鬆管理使用者訂閱、處理通知事件,並自訂應用程式的通知行為。此外掛由 OneSignal 維護,支援透過 pub.dev 進行順暢設定。非常適合需要透過通知實現即時互動的應用。

適用情境

  • 發送定向推播通知
  • 使用者參與度追蹤
  • 應用內訊息傳遞
  • 即時警告
  • 跨平台通知支援

主要特色

  • 與 Flutter 的輕鬆整合
  • 對 Android 和 iOS 的支援
  • 通知事件處理
  • 用戶訂閱管理
  • 可自訂的通知外觀

適合對象

  • 需要推送通知的移動應用
  • 使用 OneSignal 的開發人員
  • 專注於使用者參與的應用程式
  • 尋求免費通知服務的初創企業
  • 跨平台專案

使用建議

  • 需要 OneSignal 帳戶設定
  • 需要正確的 API 金鑰設定
  • 受限於 OneSignal 的後端
  • iOS 需要額外的權限
  • 需要背景執行權限

原始 README

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

OneSignal Flutter SDK Build Status

⚠️ Migration Advisory for current OneSignal customers

Our new user-centric APIs and v5.x.x SDKs offer an improved user and data management experience. However, they may not be at 1:1 feature parity with our previous versions yet.

If you are migrating an existing app, we suggest using iOS and Android’s Phased Rollout capabilities to ensure that there are no unexpected issues or edge cases. Here is the documentation for each:

If you run into any challenges or have concerns, please contact our support team at support@onesignal.com


OneSignal is a free email, sms, push notification, and in-app message service for mobile apps. This SDK makes it easy to integrate your Flutter iOS and/or Android apps with OneSignal.

Flutter Notification

Installation

See the Setup Guide for setup instructions.

Disabling OneSignal Location

If your app does not use OneSignal.Location, you can exclude the native OneSignal location module from iOS and Android builds.

For Swift Package Manager, CocoaPods, and Android Gradle builds, set ONESIGNAL_DISABLE_LOCATION=true in the environment before resolving or building. The value is case-insensitive, and 1 is also accepted.

In GitHub Actions, you can set it once at the job or step level so Swift Package Manager, CocoaPods, and Gradle builds inherit it:

env:
  ONESIGNAL_DISABLE_LOCATION: true

With the location module disabled, calls to OneSignal.Location are ignored on Android and OneSignal.Location.isShared() returns false.

CocoaPods: app extension targets

CocoaPods only builds OneSignalXCFramework once when every target in your Podfile resolves the same set of subspecs. If the sets differ, it creates one pod variant per set, and each variant tries to write the same extracted framework, which fails the build with:

error: Multiple commands produce '.../XCFrameworkIntermediates/OneSignalXCFramework/OneSignalCore/OneSignalCore.framework'

With location disabled the plugin resolves OneSignalXCFramework/OneSignal and OneSignalXCFramework/OneSignalInAppMessages, so every Notification Service Extension or Widget Extension target must declare those same two subspecs:

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework/OneSignal', '>= 5.0.0', '< 6.0'
  pod 'OneSignalXCFramework/OneSignalInAppMessages', '>= 5.0.0', '< 6.0'
end

Without the environment variable set, the plugin resolves the umbrella pod, so extension targets should declare pod 'OneSignalXCFramework' instead. Either way the rule is the same: the app target and every extension target must request an identical subspec set.

Applying the change (clearing cached packages)

The environment variable is only read when dependencies are resolved, and each platform caches the resolved set. If you change the variable on an existing project, you must clear the relevant cache and re-resolve in a shell where the variable is exported. Otherwise a stale build can keep (or drop) the location module regardless of the new value.

[!IMPORTANT] When using Xcode or Android Studio, launch the IDE from a terminal that has ONESIGNAL_DISABLE_LOCATION exported. An IDE launched from the Dock/Finder does not inherit variables set only in your shell profile.

Swift Package Manager:

flutter clean
rm -rf ios/.build
rm -rf ~/Library/Caches/org.swift.swiftpm ~/Library/Developer/Xcode/DerivedData/*
ONESIGNAL_DISABLE_LOCATION=true flutter build ios

In Xcode, you can instead use File → Packages → Reset Package Caches (with the variable exported), then build.

CocoaPods:

cd ios
pod deintegrate
rm -rf Pods Podfile.lock
ONESIGNAL_DISABLE_LOCATION=true pod install

Android Gradle (Gradle re-reads the variable on each configuration, so a clean build is usually enough):

ONESIGNAL_DISABLE_LOCATION=true flutter build apk

On CI, key any DerivedData / SwiftPM / CocoaPods / Gradle caches on the value of ONESIGNAL_DISABLE_LOCATION (or skip restoring them for no-location builds) so a restored cache does not resurrect the location module.

Change Log

See this repository's release tags for a complete change log of every released version.

Support

Please visit this repository's Github issue tracker for feature requests and bug reports related specificly to the SDK. For account issues and support please contact OneSignal support from the OneSignal.com dashboard.

Demo Project

To make things easier, we have published a demo project in the /example folder of this repository.

Supports:
  • Tested from iOS 8 to iOS 15
  • Tested from Android 4.0.3 (API level 15) to Android 12.0 (31)

所屬分類

原始碼儲存庫

使用此套件的專案