I have finally managed to fix the implementation of push notifications using the SFMC SDK. The problem I am now having is that our implementation uses custom fields to send deeplink information to the app, along with some tracking parameters. I have enquired about using openDirect/URL, but I am led to believe this would not be easy to implement, so the preference is that we handle it in the app.

From the updated React Native docs, we have the setUrlHandler method. This only seems to work with the URL field and does not take any custom params into account. I believe the data I need is in the customKeys Map, however I cannot access this within the notificationbuilder without it causing the app to crash, producing an error in the console stating that it does not have permission to run in the background because the notification priority was not set to high (something we cannot override).

Is there any way to access this information with the React Native SDK, or am I limited to using URL only?

Stack trace:

2023-07-12 11:33:53.446  1253-5533  ActivityManager         pid-1253                             W  Background start not allowed: service Intent { cmp=com.***.***/io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService (has extras) } to com.***.***/io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService from pid=6626 uid=10730 pkg=com.***.*** startFg?=false
2023-07-12 11:33:53.447  6626-6626  RNFirebaseMsgReceiver   pid-6626                             E  Background messages only work if the message priority is set to 'high'
                                                                                                    android.app.BackgroundServiceStartNotAllowedException: Not allowed to start service Intent { cmp=com.***.***/io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService (has extras) }: app is in background uid UidRecord{7d750c2 u0a730 RCVR idle change:uncachedprocstateprocadj procs:0 seq(77507179,77501446)}
                                                                                                        at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1981)
                                                                                                        at android.app.ContextImpl.startService(ContextImpl.java:1927)
                                                                                                        at android.content.ContextWrapper.startService(ContextWrapper.java:834)
                                                                                                        at android.content.ContextWrapper.startService(ContextWrapper.java:834)
                                                                                                        at io.invertase.firebase.messaging.ReactNativeFirebaseMessagingReceiver.onReceive(ReactNativeFirebaseMessagingReceiver.java:16)
                                                                                                        at android.app.ActivityThread.handleReceiver(ActivityThread.java:4894)
                                                                                                        at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2420)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8757)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Thanks, Dan

  • Can you share the stacktrace from the crash, please?
    – Bill Mote
    Jul 12 at 14:46
  • Hi @BillMote, I've edited to include. The crash occurs when I try to extend the Intent to include, for example, notificationMessage.customKeys().get("notif_type") Including this code, or even console logs (Log.e(...)) within the notification customisation code, will break the entire implementation and instead of receiving pushes, I will just see those errors. Jul 12 at 15:28
  • Note that I have implemented the onMessageReceived override and this is correctly sending messages into the SDK. With the standard implementation (taken directly from the RN SDK repo), everything works as expected and I am able to receive pushes and open the app - but I cannot access the custom keys this way. Jul 12 at 15:31
  • Do you have an open support case? If not, please open one. Any chance you have a simple 'hello world' version of this I can see? I can try to reproduce it, but that will obviously take more time. If you have more detail regarding the error that would be fantastic. 2 lines isn't very helpful.
    – Bill Mote
    Jul 13 at 12:23
  • 1
    It happens while the app is backgrounded so I'm not so sure it's an actual crash, rather than just a warning/error. Crashlytics doesn't pick anything up so I would assume the latter. But in any case, it prevents the notification from being delivered. It would be simple enough to reproduce, just run the example app from the react native repo and try to add any custom code within the body of the NotificationCustomizationOptions.create method, or the getPendingIntent method. Even simple logging commands will cause the implementation to break and spit out the warning about priority. Jul 13 at 12:48


You must log in to answer this question.