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

套件詳情v0.0.4

plain_notification_token

透過平台方式取得推送通知權杖(iOS 使用 APNs,Android 使用 Firebase Cloud Messaging)

AndroidiOS
近 30 天下載
70
喜歡數
41
Pub 分數
130

安裝套件

flutter pub add plain_notification_token

套件介紹

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

一個輕量級的 Flutter 套件,使用平台特定的方法取得推播通知權杖:iOS 使用 APNs,Android 使用 Firebase Cloud Messaging。它抽象了底層實作,讓開發者能輕鬆取得裝置權杖以發送通知。此套件設計簡潔且可靠,確保跨平台的一致性權杖存取,無需複雜設定。它可順暢整合至需要推播通知功能的應用程式中。

適用情境

  • 獲取推送通知的設備令牌
  • 與 Firebase 雲訊息傳遞整合
  • 在 iOS 上設定 APNs 權杖
  • 啟用跨平台通知支援
  • 簡化訊息應用中的權杖取得

主要特色

  • 平台特定的令牌檢索
  • 最小化樣板
  • 支援 Android 和 iOS
  • 與 FCM 和 APNs 的輕鬆整合
  • 輕量且無依賴

適合對象

  • 需要推播通知的應用
  • 使用 FCM 或 APNs 的開發人員
  • 優先考慮簡單性的專案
  • 跨平台移動應用
  • 管理設備令牌的後端服務

使用建議

  • 需要正確設置 FCM 或 APNs
  • 不會自動處理權杖刷新
  • 沒有內建的網路問題錯誤處理
  • 僅限令牌檢索
  • 依賴外部服務進行實際訊息傳遞

原始 README

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

plain_notification_token

Get your push notification token via platform way (APNs for iOS / Firebase Clound Messaging for Android)

Getting Started

Android Integration

To integrate your plugin into the Android part of your app, setup Firebase:

  1. Using the Firebase Console add an Android app to your project: Follow the assistant, download the generated google-services.json file and place it inside android/app.
  2. Modify the android/build.gradle file and the android/app/build.gradle file to add the Google services plugin as described by the Firebase assistant.

(Please see this tutorial if you want.)

iOS Integration

To integrate your plugin into the iOS part of your app, follow these steps:

  1. Generate the certificates from Apple developer center for receiving push notifications. (Please see this article if you want the tutorial.)
  2. Enable Push Notification in Capabilities tab in Xcode opening your ios/Runner.xcworkspace.

Enabling Push Notification switch

Dart/Flutter Integration

From your Dart code, you need to import the plugin and instantiate it:

import 'package:plain_notification_token/plain_notification_token.dart';

final plainNotificationToken = PlainNotificationToken();

To get token, call getToken():

// (iOS Only) Need requesting permission of Push Notification.
if (Platform.isIOS) {
  plainNotificationToken.requestPermission();
  
  // If you want to wait until Permission dialog close,
  // you need wait changing setting registered. 
  await plainNotificationToken.onIosSettingsRegistered.first;
}

final String token = await plainNotificationToken.getToken();

... and use token on your server!!

Token is Base64 stringified APNs token (in iOS) / Firebase Cloud Messaging (FCM) string token (in Android).

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案