Monday, January 22, 2024
HomeiOS Developmentswift - Flutter ios Deal with background notification in terminated standing app

swift – Flutter ios Deal with background notification in terminated standing app


i’ve a problem when dealing with silent push in my app when the person shut the app, right here is my native code which works like appeal when the app within the foreground, background or terminated standing from a short while from closing the app, and after very long time from closing it (+30min) it won’t work anymore, it make me confuse why it doesn’t work and different messaging app like viber, whatsapp and messanger you’ll be able to nonetheless obtain messages and calls even you swipe the app and shut it !! is there any factor should i add !!

override func utility(_ utility: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
            Messaging.messaging().appDidReceiveMessage(userInfo)
            if Auth.auth().canHandleNotification(userInfo) {
                completionHandler(.noData)
                return
            }
        
        // pattern notification for testing
            let content material = UNMutableNotificationContent()
            content material.title = "Hello there"
            content material.physique = "Simply check"
            content material.sound = UNNotificationSound.default
            
            let request = UNNotificationRequest(identifier: "helloNotification", content material: content material, set off: nil)
            
            UNUserNotificationCenter.present().add(request) { (error) in
                if let error = error {
                    print("Error including notification request: (error.localizedDescription)")
                }
            }
        // resent to dart aspect
        let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
        let notificationChannel = FlutterMethodChannel(identify: "notificationHandler", binaryMessenger: controller.binaryMessenger)
        var dataToSend: [String: Any] = [:]

        if let textual content = userInfo["text"] as? String {
            dataToSend["text"] = textual content
        }
        
        // Convert the dictionary to NSDictionary
        let nsDataToSend = NSDictionary(dictionary: dataToSend)


        // Move the NSDictionary to Dart
       ```
i double checked :

background capabilities : distant notifs, background fetching, voip, background processing


I attempted utilizing background handler of firebase_messaging and deal with it natively utilizing swift and similar drawback, the app cease dealing with silent push after closing it after a short while



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments