infobip / mobile-messaging-react-native-plugin

Mobile Messaging SDK plugin for React Native projects
24 stars 4 forks source link

messageReceived Library Event on iOS Devices Not Triggering #72

Open moustafadevrn opened 1 month ago

moustafadevrn commented 1 month ago

Description: The messageReceived library event works successfully on Android devices but does not trigger on iOS devices. This inconsistency needs to be addressed to ensure the functionality is consistent across both platforms.

Steps to Reproduce: Implement the messageReceived event in the app. Trigger an event that should activate messageReceived. Observe the behavior on Android and iOS devices.

Expected Behavior: The messageReceived event should trigger consistently on both Android and iOS devices.

Actual Behavior: The event triggers as expected on Android devices but does not trigger on iOS devices.

fortesdev commented 1 month ago

Hi @moustafadevrn, in our Example app (included within the SDK), HomeScreen.js file, function HomeScreen, block code of useEffect, I added the following:

mobileMessaging.subscribe( 'messageReceived', eventData => { console.log('Event received', eventData); } );

Then I triggered a notification through chat message, broadcasted a regular push, and also a In-App push through Moments, and all three printed the 'Event received' and its content on my real iOS device, even with the app in background. I don't know what the issue in your end is, could you please retry with our Example app perhaps?

moustafadevrn commented 4 weeks ago

Hello @fortesdev

Thank you for your suggestion. I actually tried the same line of code you mentioned. However, the event is not triggered as you suggested.

As I mentioned before, the notification is not received while the app is in the foreground.

Furthermore, I have searched for the code block you mentioned in the HomeScreen.js file located in the Example folder of the SDK, but I couldn't find any code like that.

fortesdev commented 3 weeks ago

Hi @moustafadevrn,

I wrote that "I added" that line of code (that you can write as well, not to search for it), in line 11 here.

And it works on my testing: App in foreground, broadcasting regular push => event received (notification not visible as it is silent) App in foreground, chat message received, but chat not present => event received (notification visible) App in foreground, chat message received, but chat present => event and notification not received by design, as explained here.

If you still face issues, feel free to check/share [MobileMessaging] console logs (excluding your ids/secrets), but also test with our Example if possible.