Closed Erchil66 closed 1 month ago
I'm also facing same issue. For me it's working on android device after updating the package version to 17.2.2.
Same issue here.
@MaikuB can you help us? on This?
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
Add These to your AppDelegate.swift
and it should work
@1AhmedYasser Now it's working, thanks for the help.
@1AhmedYasser Thanks for your great help. Now its working fine for me.
Yes, Same for me, Kinda need to update the doc, This might also need for further configuration for IOS.
Thanks @1AhmedYasser ,
@1AhmedYasser would like to have some another help also,
as my current appdelegate
import Flutter
import UIKit
import FirebaseCore
import flutter_local_notifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
}
This works on debug but on release it's just do nothing again, Any idea?
@1AhmedYasser would like to have some another help also,
as my current appdelegate
This works on debug but on release it's just do nothing again, Any idea?
I Checked on my side from debug and release using flutter run --debug
& flutter run --release
and it worked on both
here is my AppDelegate.swift
import UIKit
import Flutter
import CleverTapSDK
import clevertap_plugin
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
CleverTap.autoIntegrate()
CleverTapPlugin.sharedInstance()?.applicationDidLaunch(options: launchOptions)
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel(name: "iOSChannel",
binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler {(call: FlutterMethodCall, result: FlutterResult) -> Void in
if (call.method == "activityIndicator") {
let status = call.arguments as? Bool
if (status == true) {
print("show")
UIApplication.shared.isNetworkActivityIndicatorVisible = true
} else {
print("hide")
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}
return
}
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
}
Also make sure the configurations are correct
Version status
Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2663184aa7 (10 days ago) • 2024-09-11 16:27:48 -0500
Engine • revision 36335019a8
Tools • Dart 3.5.3 • DevTools 2.37.3
Am gonna close this ticket
@1AhmedYasser again thank you.
i solved mine by adding the body notification, Am only passing data, So in this kinda weird due when not included the notifcation field the notification can't be tap
sample body sending message:
{
"message": {
"token": "token_user",
/// If i remove notification body the notification heads-up tapping it, Won't work.
"notification":{
"title":"Some Title",
"body":"Some long body description"
},
"data": {
"id": "122",
"type": "message"
}
}
}
As my current appdelegate:
import Flutter
import UIKit
import FirebaseCore
import flutter_local_notifications
// Added some import
import UserNotifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
FirebaseApp.configure()
// Added some code ----> START
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in }
/// END <-----
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
}
Describe the bug When app is open or foreground, Then tapping notification doesn't do anything in IOS.
To Reproduce
Expected behavior Should redirect to page,Platform is IOS
Sample code to reproduce the problem I created a singleton file for notification with firebase as my current code: It's working well on Android, It do redirect when tapping.
as my app delegate file
Appdelagate file