Skip to content

Use RNFirebase with OneSignal - iOS #958

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

Closed
rborn opened this issue Mar 13, 2020 · 10 comments
Closed

Use RNFirebase with OneSignal - iOS #958

rborn opened this issue Mar 13, 2020 · 10 comments

Comments

@rborn
Copy link

rborn commented Mar 13, 2020

Description:
I am trying to use RNFirebase local scheduled notification in the same time with remote notifications from OneSignal.

The issue is that while the local scheduled notification is displayed I don't receive any callback event. This only happens on iOS, on android it works so far.

I tried everything I could (my objC-fu is not as good) but I could not manage to make it work.

At some point I added [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; and onNotificationOpened started to trigger however OneSignal stopped to work :(

I also tried to disable swizzling in Firebase but it made no difference.

Any help or idea would be appreciated, I'm kind of stuck here and don't know how to fix this. Thank you 😻

Environment

OneSignal React-Native SDK : 3.6.5
RNFirebase: 5.6.0

@rborn
Copy link
Author

rborn commented Mar 16, 2020

@rgomezp @Nightsd01 could you give me some help this? OneSignal is not providing a way to make local notifications and postMessage is not an option for us (it has to be a reminder, locally on the device)

No matter what I try I don't manage to make this work - spent already a few days only on this- and my objC is pretty rusty :(
Thanks in advance!

@rborn
Copy link
Author

rborn commented Mar 16, 2020

fwiw I tried also https://github.com/react-native-community/react-native-push-notification-ios .
Same result, no luck :(

@jkasten2
Copy link
Member

@rborn OneSignal does swizzle the UNUserNotificationCenter so even if you have [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; in your code it shouldn't break OneSignal.
https://github.com/OneSignal/OneSignal-iOS-SDK/blob/2.12.6/iOS_SDK/OneSignalSDK/Source/UNUserNotificationCenter%2BOneSignal.m#L74
Could you share your code where you are calling this?

Before I dig into the code to far RNFirebase is this RNFirebase: 5.6.0?
https://github.com/invertase/react-native-firebase

I looked at the setup guide for react-native-push-notification-ios and it is incomplete.
https://github.com/react-native-community/react-native-push-notification-ios/blob/9fbb9beeb9c65243e3462bd7a7da5d9ef2ecff72/README.md#update-appdelegatem

When you setup the UNUserNotificationCenter delegate you need to setup BOTH it's method and call the matching RNCPushNotificationIOS methods.
That is because when a UNUserNotificationCenter delegate is set the matching AppDelgate methods won't fire. that is application:didReceiveLocalNotification and application:didReceiveRemoteNotification:fetchCompletionHandler: on the AppDelegate won't fire. This behavior is built into iOS, and UNUserNotificationCenter should be using going forward as these AppDelegate methods have been deprecated for a number of years.
https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622930-application?language=objc

@rborn
Copy link
Author

rborn commented Mar 17, 2020

@jkasten2 thanks, yes it's 5.6.0 (didn't move to 6 as it doesn't have notifications)
I have some results with react-native-push-notification-ios and tried to replicate them to RNFirebase but is not fully working.

react-native-push-notification-ios also has issues to get the initialNotification but I found a workaround (they seem not wait for RN to initialise so the info is lost)

@rborn
Copy link
Author

rborn commented Mar 18, 2020

@jkasten2 small update, I managed to do "something" with react-native-push-notification (that mixes react-native-push-notification-ios and own android code ) but it's not ideal as they have both bugs and/or are old modules and I need to workaround many things. It also means I need to add another module to the app which adds weight.

I tried to replicate what I did with the RNFirebase v5.6.0 module but I only have very limited results.

It would be amazing to manage to make it work (even if in time will become obsolete as v6 won't have notifications soon) and have it in one place only. Maybe you could take a look ?

Ideally I think OneSignal could implement localNotifications, even if it's not the scope but would give a lot of value to the devs and way less Github issues for you guys 😊

I'm not a native guy but I can help with testing in case you decide to do something about this 🤗
Thank you.

@rgomezp
Copy link
Contributor

rgomezp commented Apr 7, 2020

Thanks for your suggestion @rborn . We will definitely take your suggestion into consideration.

Can you provide more details regarding the "limited results" you are seeing? What behavior is occurring?

Edit: also, please upvote this issue with React Native

@rborn
Copy link
Author

rborn commented Apr 8, 2020

@rgomezp hi, thanks for the reply
By "limited results" I mean I'm not able to make it work, the local notification executes (I see it in the native logs) but (due to the delegate I think) is not triggering any event or notification.

@rgomezp
Copy link
Contributor

rgomezp commented Apr 8, 2020

Howdy @rborn,
My pleasure. Is it okay if I close this issue and you can just follow the progress in the React Native repo issue?

@rborn
Copy link
Author

rborn commented Apr 9, 2020

@rgomezp Ok, thank you. What about the local notifications directly from OneSignal, any plans for this?

@rgomezp
Copy link
Contributor

rgomezp commented Apr 9, 2020

Howdy @rborn,
Currently, no. Not because we don't want to but rather simply due to bandwidth. It is definitely something we will consider for the future. Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants