When you need to guarantee that your messages are delivered even during reconnection events, you need to use the subscribeWithBuffer (or subscribeWithOptions) method.
This method has a subscriberId parameter to uniquely identify each specific subscriber. This way the Realtime server can be aware of which messages were already delivered to each subscriber.
Since this parameter must be unique for each subscriber, it's a best practice to use some user property that doesn't change over time, like the user id in your app context.
You can learn more about the Realtime message delivery modes at http://messaging-public.realtime.co/documentation/starting-guide/delivery-modes.html