Skip to main content

本地通知

使用 flutter_local_notification 實作,細節可參考原專案

注意

若未設定此頁面會影響以下功能

限制

目前只支援 AndroidiOSmacOS 系統,並有以下限制

設定

Android

需至 AndroidManifest.xml 設定 可參考

app/scr/main/res/drawable 加入 ic_stat_name.png,此圖是在通知顯示時在狀態列(status bar)顯示的圖案

iOS

Runner 中的 AppDelegate.m/AppDelegate.swift

加入下列程式碼在 didFinishLaunchingWithOptions 方法下

Objective-C:

AppDelegate.m
if (@available(iOS 10.0, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;
}

Swift:

AppDelegate.swift
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}

開啟 XcodeRunner 中的 Signing & Capabilities 加入 Push Notification 的權限

macOS

開啟 XcodeRunner 中的 Signing & Capabilities 加入 Push Notification 的權限