I'm facing an issue with my Ionic project (v6) using Capacitor (v4.4.0). I am trying to establish communication between the Swift layer in AppDelegate.swift and a Typescript class, but have been unsuccessful so far.
Whenever something happens in AppDelegate.swift, I need to notify my Typescript class to perform certain actions. I have tried using NotificationCenter for this purpose. In my Swift file, I have added the following code:
NotificationCenter.default.post(name: NSNotification.Name("somethingHappened"), object: nil, userInfo: userInfo)
On the Typescript side, I have implemented a NotificationService class that listens for the 'somethingHappened' event using Capacitor's App plugin. However, despite my efforts, the listener does not seem to be triggered when running the app on iPhone.
I have considered using a bridge between Swift and Typescript, but it seems that the bridge is not compatible with Capacitor 4.4.0. Therefore, I am stuck and seeking guidance on how to effectively communicate between these two layers in my Ionic project.
If anyone has any insights or suggestions on how to resolve this issue, I would greatly appreciate it!