Class BridgeManager

java.lang.Object
com.subaio.fintechbridge.BridgeManager

public final class BridgeManager extends Object
Singleton-class for managing global setup of BridgeViews. Before creating views, `BridgeManager.getInstance().configure` and `BridgeManager.getInstance().setLanguage should be invoked. The manager automatically maintains a valid token and requests new ones using the `TokenHandler.onTokenRequired` callback whenever necessary.
  • Constructor Details

    • BridgeManager

      public BridgeManager()
  • Method Details

    • getInstance

      public static BridgeManager getInstance()
      Shared instance of the Subaio Manager. Use this to set token and configure Subaio.
      Returns:
      BridgeManager
    • configure

      public void configure(@NonNull String baseUrl, @NonNull String language, @NonNull BridgeManager.TokenHandler tokenHandler, @NonNull RequestHandler requestHandler, Map<String,String> customConfig, boolean allowExternalUrls, boolean allowShare, boolean allowDialogs, int initializationTimeoutMillis) throws MalformedURLException
      Configure Subaio Manager to use specified configuration object. It is recommended to use the fluent interface accessible by calling startConfiguration instead of calling configure manually.
      Parameters:
      baseUrl - URL pointing to root of Subaio template, e.g. if template is at `https://www.bar.foo/template`, then baseUrl should be `https://www.bar.foo`
      language - BCP-47 language tag
      tokenHandler - Handle requests for authentication tokens
      requestHandler - Request handler used for SSL pinning requests
      customConfig - Custom named values (such as customizable colors) sent to the views.
      allowExternalUrls - Allow opening of external urls
      allowShare - Allow sharing events
      allowDialogs - Allow opening dialogs
      Throws:
      MalformedURLException
    • startConfiguration

      public ConfigurationHelper startConfiguration()
      Start configuration flow with fluid interface. Call .apply() to finish configuration. You must call setBaseUrl, setLanguage, setTokenHandler and setRequestHandler as part of the configuration.
    • setLanguage

      public void setLanguage(@Nullable String language)
      Language to be used by all Subaio views as a BCP-47 string. Assigning `language` automatically updates all views and triggers a token refetch if configure has already been called. If it is set to nil or not set, views will never exit their loading-state.
      Parameters:
      language - Language code.
    • setCustomConfig

      public void setCustomConfig(@Nullable Map<String,String> customConfig)
    • getLanguage

      @Nullable public String getLanguage()
      Current language as a BCP-47 string.
      Returns:
      language code.
    • getCustomConfig

      @Nullable public Map<String,String> getCustomConfig()
    • getToken

      @Nullable public Token getToken()
      Token to be used by Subaio for all calls to Subaio backend.
    • getTemplateHelper

      public com.subaio.fintechbridge.TemplateHelper getTemplateHelper()
    • setTokenHandler

      public void setTokenHandler(BridgeManager.TokenHandler tokenHandler)
    • getIsConfigured

      public boolean getIsConfigured()
    • getInitializationTimeoutMillis

      public int getInitializationTimeoutMillis()
    • refreshToken

      public void refreshToken()
      Force a refresh of the token. This is necessary if the user changes authentication status (user logs out, user logs in, user is changed) to ensure that the token (or lack thereof) is correct. Only works after configure and setLanguage has been called.
    • prewarm

      public void prewarm(@NonNull android.content.Context context)
      Read currently cached base-HTML/placeholder images. If no cache exists, it is fetched asynchronously. Optionally call to avoid a flash of white when creating the very first BridgeView. If not called, this is automatically handled as part of view creation.