A Branch link in iOS parlance is an "app link": Basically, a URL starting with http(s). A traditional deep link in iOS is using your own defined scheme in place of http(s): Something like myFooScheme://foo/bar.
iOS will not allow your app to open http(s) "app links" from inside your app. So, using a Branch app link inside a push or in-app will always take the user to Safari rather than deep link into the app. This is an OS-level limitation.
The solution is to use your own custom scheme, i.e., myFooScheme://foo/bar instead so the OS will always open your own scheme from inside the app if you have registered it as such.
So, for push and in-app you can never use an http(s) app link as the deep link scheme; you must register and use your own custom scheme - scheme being the url protocol - http(s):// vs myCustomScheme://
The general point about iOS app links is that with an "app link" depending on the user context the OS will either deep link into your app or open your website so if the app link is clicked from outside your app, the OS thinks that the user wants to go inside the app and it deep links into the app.
However, if the link is triggered from inside the app the OS thinks that since the user is already inside the app, they must now want to go to the website.