Closed JoseFMP closed 5 years ago
Is the other console.log being called? Can you share the full index.js or your entry file?
@jinshin1013 I updated it in the original message. So whatever is not related to the event is working fine. But the event is not triggered.
Do you get any errors? or just blank screen?
@jinshin1013 I get no error, just blank screen and the event no triggered (i.e. debugger does not stop in break points in the callback, the log messages do not appear, I also tried to throw errors in the block to see if they would appear).
It may sound stupid but you did follow all the instruction to install react-native-navigation, right? If you could prep up a reproducible project on your Github, I could have a look at it. There isn't really anything any of us could do without more info.
It may be due to react-native-navigation not supporting RN ^0.58. Try downgrading to 0.57.8 and see if it builds.
@jinshin1013 Yes I followed the instructions. I will share it if necessary but it is really just a boiler plate. I will try to downgrade and see what happens.
I had the same and saw your issue. The mistake I made was that the listener was registered too early. Try to register the listener (with a console.log
) as soon as possible. Hope it works for you!
We use the issue tracker exclusively for bug reports and feature requests. This issue appears to be a general usage or support question. Instead, please ask a question on Stack Overflow with the react-native-navigation
tag.
@bobmulder Can you rephrase or elaborate on what your solution was? I'm not clear on what it means to register the listener too early or how you changed that. Are you doing something different than the example in the documentation (which is not working for me, even after downgrading RN to 0.57.8)
Same problem here, in iOS it works, while in Android the event is never triggered.
@bobmulder @dmchoull Have you found a solution to the problem?
@marf No, unfortunately not. I've just switched to using react-navigation for now
@marf @dmchoull @bobmulder
I was experiencing the same issue. On iOS the event was fired, on Android it wasn't.
In my case, setting the registerAppLaunchedListener before the promised did the trick.
So changing this:
Promise.all([
Icon.getImageSource(Platform.OS === 'android' ? "md-map" : "ios-map", 30),
Icon.getImageSource(Platform.OS === 'android' ? "md-list" : "ios-list", 30),
Icon.getImageSource(Platform.OS === 'android' ? "md-more" : "ios-more", 30)
]).then(sources => {
console.log('Loaded sources'); // <-- This one does fire on android
Navigation.events().registerAppLaunchedListener(() => {
console.log('App launched'); // <-- This one doesn't fire on android
...
});
})
to this:
Navigation.events().registerAppLaunchedListener(() => {
Promise.all([
Icon.getImageSource(Platform.OS === 'android' ? "md-map" : "ios-map", 30),
Icon.getImageSource(Platform.OS === 'android' ? "md-list" : "ios-list", 30),
Icon.getImageSource(Platform.OS === 'android' ? "md-more" : "ios-more", 30)
]).then(sources => {
console.log('Loaded sources'); // <-- This one does fire on android
})
})
Your case might be different. But this did the trick for me. Hope it helps.
"Register the listener with registerAppLaunchedListener as soon as possible - it should be one of the first lines in your index.js file. If you're observing a "white screen" or a hanging splash screen after relaunching your app, it probably means Navigation.setRoot isn't called once the app has launched. Perhaps the listener was registered too late." - From the docs
Issue Description
The event
is never trieggered.
Steps to Reproduce / Code Snippets / Screenshots
registerAppLaunchedListener
event.index.js
:console.log('Trying to subscribe to AppLaunched event'); // this line is hit Navigation.registerComponent('LandingScreen', componentGenerator); Navigation.events().registerAppLaunchedListener(() => { console.log('Hello world'); // this line is never hit Navigation.setRoot({ root: { component: { name: 'LandingScreen', id: 'LandingScreen', } } }); }); console.log('Finished subscribing to event'); // this line is hit