Comments (7)
Can you share more details please? Maybe post some code?
from swifteventbus.
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.
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.
so it must make AppDelegate the listener?
from swifteventbus.
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.
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.
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)
- WatchOS support HOT 1
- why the versoin is also 2.2.0 HOT 3
- should I call SwiftEventBus.unregister(self) in deinit HOT 1
- Your 3.0.0 tag has the wrong podspec version (2.2.0) HOT 1
- can't get the newest version in the standard way
- How to create an new instance HOT 1
- Conflicting overloading functions HOT 2
- Publish 3.0.1 to Cocoapods HOT 1
- Update swift version to 5
- Swift Package Manager HOT 5
- Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.1 compiler: HOT 3
- Static.instance.cache is not clearing automatically unless unregister the target
- compiler warning HOT 1
- Check if event is already registered HOT 4
- Cocoapods downloads 5.0.0 instead of the latest
- Module compiled with Swift 5.3.2 cannot be imported by the Swift 5.4.2 compiler HOT 2
- Update podspec to 5.1.0 HOT 1
- event only triggered once
- Could you add the SWIFT_VERSION attribute in at least one of the targets? HOT 1
- Why hasn't it been updated in years
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swifteventbus.