本地通知
使用 flutter_local_notification 實作,細節可參考原專案
注意
若未設定此頁面會影響以下功能
- 使用到 NotifcationUtil 的功能
- 課表骨架 中的上課提醒
限制
目前只支援 Android 、 iOS 、 macOS 系統,並有以下限制
- Android 4.1+. 使用 NotificationCompat APIs 所以能跑在較舊的 Android 裝置
- iOS 8.0+. iOS 10 以下使用 UILocalNotification APIs. iOS 10 以上(包含)使用 UserNotification APIs (aka the User Notifications Framework)
- macOS 10.11+. 在 macOS 10.14 以下使用 NSUserNotification APIs 在 macOS 10.14 以下使用 UserNotification APIs (aka the User Notifications Framework)
設定
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
}
開啟 Xcode 在 Runner 中的 Signing & Capabilities 加入 Push Notification 的權限
macOS
開啟 Xcode 在 Runner 中的 Signing & Capabilities 加入 Push Notification 的權限