I have found a workaround, from this post by u/stevenson. In my implementation, the view that needs data scanned into it from the session event first sets a session.custom property to the value of the return ID I wanted as context for the barcode scanner event, then the barcode scanner reads this session.custom property to provide the correct returnID in the payload of the barcodeScanned message.
I think that the session custom variable is an inelegant solution, but the only one I can think of without a way to activate the session barcode scanner using a system method.