일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 소개팅앱 만들기 stomp
- Firebase authentication android apple login
- Supabase edge function
- Supabase edge function insert data
- 주 4일 근무제 log
- DT_TOOLCHAIN_DIR cannot be used
- supabase edge function deploy error supabaseurl is required
- Stomp user connection event
- no such module '__ObjC'
- Spring google SMTP settings
- supabase edge function deploy error
- 소개팅앱 만들기 flutter
- Firebase authentication android apple login setting
- invite user for supabase project
- Firebase authentication apple login 최신
- 주 4일 근무제
- supabase storage public url not working
- stable-diffusion-webui local 네트워크에서 접속
- stable-diffusion-webui local 접속
- 주 4일 근무제 경험담
- Android apple login
- 로컬 서버 접속
- 소개팅앱 만들기
- Android apple login identifier
- Spring LocalDateTime response array
- Android apple login 인증서 설정
- Stomp socket connection event
- supabase storage feature not enabled for this tenant
- Spring boot swagger blank screen
- Firebase authentication apple login
Archives
- Today
- Total
꿀맛코딩
Flutter module local notification foreground push in ios not working 본문
공부방/Flutter
Flutter module local notification foreground push in ios not working
soycrab 2023. 8. 29. 17:32Flutter module을 가지고 이것 저것 테스트 하는데 이상한 현상이 있어서 기록해요.
Flutter module에서 Local notification 기능을 넣고, 그 상태로 iOS에서 로컬 푸시를 보내면 Foreground background 아주 잘 오는데 이상하게 이 module을 다시 native iOS에 넣어서 테스트를 하면 foreground 에서는 푸시가 오지 않는 현상이 있습니다.
이것을 해결하기위해 아래 처럼 코드를 수정을 하면 정상 동작을 확인할수 있습니다.
//
// moduletestApp.swift
// moduletest
import SwiftUI
import Flutter
// The following library connects plugins with iOS platform code to this app.
import FlutterPluginRegistrant
class FlutterDependencies: ObservableObject {
let flutterEngine = FlutterEngine(name: "my flutter engine")
init(){
// Runs the default Dart entrypoint with a default Flutter route.
flutterEngine.run()
// Connects plugins with iOS platform code to this app.
GeneratedPluginRegistrant.register(with: self.flutterEngine);
}
}
@main
struct moduletestApp: App {
// init() {
// if #available(iOS 10.0, *) {
// UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
// }
// }
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject var flutterDependencies = FlutterDependencies()
var body: some Scene {
WindowGroup {
ContentView().environmentObject(flutterDependencies)
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
// 앱이 켜졌을때
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// 원격 알림 등록
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
return true
}
}
extension AppDelegate : UNUserNotificationCenterDelegate {
// 푸시메세지가 앱이 켜져 있을때 나올때
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
print("willPresent: userInfo: ", userInfo)
completionHandler([.banner, .sound, .badge])
}
// 푸시메세지를 받았을 때
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
print("didReceive: userInfo: ", userInfo)
completionHandler()
}
}
반응형
'공부방 > Flutter' 카테고리의 다른 글
flutter SystemUiMode 옵션 정리 (0) | 2023.09.01 |
---|---|
Flutter module MissingPlugin 주의사항 (0) | 2023.08.30 |
Flutter module 네이티브(Android, iOS) import 방법 (0) | 2023.08.25 |
Execution failed for task ':app:mapDebugSourceSetPaths' (0) | 2023.08.14 |
Flutter shorebird code push for android (0) | 2023.08.10 |
Comments