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
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.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.