-
Notifications
You must be signed in to change notification settings - Fork 253
Description
Is your feature request related to a problem? Please describe.
The problem is a scoping issue: PayPalClient is effective Activity-scoped, since it needs an Activity reference in its constructor, but onBrowserSwitchResult() doesn't actually need an Activity reference at all and could be Application-scoped.
Describe the solution you'd like.
I'd like to separate concerns of the PayPalClient (and it's underlying dependencies, BraintreeClient and BrowserSwitchClient) a bit so that I can call PayPalClient.onBrowserSwitchResult() without requiring an Activity instance.
From what I can tell, BraintreeClient and BrowserSwitchClient can both satisfy the needs of onBrowserSwitchResult() with only a Context reference (since they end up calling Context.getApplicationContext() internally), but since is routed through the PayPalClient, there's no way to call onBrowserSwitchResult() today without requiring an Activity.
If I could just construct a BraintreeClient and call BraintreeClient.onBrowserSwitchResult() directly, that would work (but that function is restricted/internal).
My use case revolves around certain UI screens that observe the results of the browser redirect being re-used in multiple Activities, depending on which app flow originated the PayPal account creation flow. I would prefer to handle the browser redirects and forward them into the SDK in one place (in a BroadcastReceiver or some other Application-scoped object) instead of configuring the browser redirect to work with multiple Activities, but that doesn't seem possible today.
My ideal solution(s):
- Separate out the
onBrowserSwitchResult()part of thePayPayClientinto some new object (e.g.PayPalBrowserRedirectClient) that only requires aContext - Keep
PayPalClientas-is, and offer a different way to send browser redirect results into theBraintreeClientor its underlyingBrowserSwitchClient