Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using RSF in react-native (messaging channel not subbed to setBackgroundMessageHandler) #627

Open
tad3j opened this issue Jan 29, 2020 · 0 comments

Comments

@tad3j
Copy link

tad3j commented Jan 29, 2020

For the most part (auth and firestore modules) I was able to use this great package without any issues. Today I was implementing notifications and I've noticed that this library only subscribes to var unsubscribe = messaging.onMessage(emit); which results in notifications being emited only when app is open. https://github.com/n6g7/redux-saga-firebase/blob/master/src/messaging.js#L12

There is another event messaging.setBackgroundMessageHandler (which turns out it also works in JS version of firabase), which emits a message while app is not open (in background), which is usually more important on mobile devices.

Would there be a way to add this subscription?

I was looking through the code but I'm not sure if I could just add another subscriptions on line 12 and then somehow combine them (since message emitted is of same class in both cases), or would we need a completely new channel (according to code copy pasting function channel() should be easy to do, but is there a better way?). If anyone can show me how it should be done I'm also willing to get my hands dirty. :)

EDIT: After trying to copy channel() code I fugured that same approach won't work, since onMessage seems like expecting generator, but setBackgroundMessageHandler requires a callback that returns a promise. I guess that's why it doesn't fit into saga world?

@tad3j tad3j changed the title Using redux-saga-firebase in react-native (messaging module not subbed to setBackgroundMessageHandler()) Using redux-saga-firebase in react-native (messaging module not subbed to setBackgroundMessageHandler) Jan 29, 2020
@tad3j tad3j changed the title Using redux-saga-firebase in react-native (messaging module not subbed to setBackgroundMessageHandler) Using RSF in react-native (messaging module not subbed to setBackgroundMessageHandler) Jan 29, 2020
@tad3j tad3j changed the title Using RSF in react-native (messaging module not subbed to setBackgroundMessageHandler) Using RSF in react-native (messaging channel not subbed to setBackgroundMessageHandler) Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant