Coder Social home page Coder Social logo

Comments (7)

nunogoncalves avatar nunogoncalves commented on May 24, 2024 1

Can you share more details please? Maybe post some code?

from swifteventbus.

malkabani avatar malkabani commented on May 24, 2024

The app is in killed (not running and not in background), and new notification arrived and the user clicks on it in notification center, it will open the app.
And notification handler is fired and read notification data.
this I call
SwiftEventBus.post("receiveChatNotification")
but

SwiftEventBus.onMainThread(self, name: "receiveChatNotification") { (notification) in
print("receiveChatNotification")
}
not fired and didn't print anything on log.

but when the app is running and we call
SwiftEventBus.post("receiveChatNotification")

so
SwiftEventBus.onMainThread
will fire and code inside it running normally.

from swifteventbus.

nunogoncalves avatar nunogoncalves commented on May 24, 2024

Two things that come to my mind:
Are you sure the post gets called?

Who is the listener? AppDelegate or another ViewController? If it's another view controller, make sure it has been loaded, otherwise it doesn't exist, and therefore can't listen to the event, right? :)

from swifteventbus.

malkabani avatar malkabani commented on May 24, 2024

so it must make AppDelegate the listener?

from swifteventbus.

nunogoncalves avatar nunogoncalves commented on May 24, 2024

Depends, on what kind of logic you want to implement. If you want to show something to the user you need to load your view controller before sending the post. If you want your view controller to be the listener it has to be loaded, right? If an object doesn't exist, it can't do much. :) 💀

from swifteventbus.

malkabani avatar malkabani commented on May 24, 2024

I need to open chatViewController after a user makes click on the notification. with two situations ( an app is running and another viewController appear - an app is not running).

so I need to make appDelegate is the listener. is this best practices?

from swifteventbus.

nunogoncalves avatar nunogoncalves commented on May 24, 2024

My advice is that you load your navigation (supposing you need to go through 3 ou 4 screens before reaching that screen responsible) and you either pass the information down the chain (app delegate instanciates root view controller, and passes that info, then root VC passes to VC1, which passes to your destination VC), or you make the post on the app delegate after you know the app delegate has been loaded. I'm not sure what the best practice is, it really depends on your case.

You can also save that info on a variable (static var, user defaults, or even database...) and use it on the view controller when it loads.

from swifteventbus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.