-1

I'm using react-native-firebase for getting new notification

  • I would like to send from fcm data-only message, but i can't save this data when IOS app is closed or in background.

  • For android the solution is 'Headless JS', so if someone know any solution like Headless JS for IOS it's will be helpful.

https://rnfirebase.io/docs/v5.x.x/messaging/introduction

  • I was looking for IOS background services but all of them working every some minutes and i need to be a real time app
Barak
  • 654
  • 13
  • 30
  • try using the new firebase API and send a data-only payload for android and for iOS, send a payload with notification and data. data only payloads aren't guaranteed to deliver in iOS. – Derryl Thomas Mar 02 '20 at 18:18
  • @Derryl Thomas Thank you for your respond, im using the new firebase API but there is still no solution for saving data only messages for IOS when the app is in background or died (background service like Headless JS in android) :/ – Barak Mar 04 '20 at 12:19
  • May I ask why you want to send a data-only message for iOS? Are you trying some sort of silent notification? – Derryl Thomas Mar 04 '20 at 13:06
  • I want to save some data in realm on the mobile (when the app died or in background), and then i can delete that data from my db in the server - like WhatsApp does with messages – Barak Mar 04 '20 at 13:53

1 Answers1

0

I believe what you are trying to achieve is a silent notification. To achieve this you need to send content_available as true in your FCM payload.

However, as mentioned in the documentation:

"Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc"

Refer this SO question for more details on how to achieve silent notifications.

Derryl Thomas
  • 1,324
  • 12
  • 22
  • Thank you for answering, but my problem is that in IOS the silent notification execute just when the app is open again , and doesn't work when the app closed( i want to execute some process when the app closed and getting this data notification). I tried what they suggest but it didn't help me. – Barak Mar 21 '20 at 12:51
  • Alright, I understand, try my answer here - https://stackoverflow.com/a/60596627/10578421. If it works for you, I'll update this answer with the same info. – Derryl Thomas Mar 22 '20 at 19:22
  • Yes i though about doing that too but i don't know how to connect between the UNNotificationServiceExtension to my code in react-native -(get it in messageListener where react-native-firebase take a part - and then i can do my process) – Barak Mar 22 '20 at 20:51