Package com.unblu.sdk.core.links
Class UnbluPatternMatchingExternalLinkHandler
java.lang.Object
com.unblu.sdk.core.links.UnbluPatternMatchingExternalLinkHandler
- All Implemented Interfaces:
UnbluExternalLinkHandler
public class UnbluPatternMatchingExternalLinkHandler
extends Object
implements UnbluExternalLinkHandler
An implementation of the
UnbluExternalLinkHandler interface.
This implementation checks links against a list of link patterns and returns UnbluExternalLinkHandlingPolicy.OPEN if the link matches a pattern.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.UnbluPatternMatchingExternalLinkHandler(List<Pattern> patternList) This constructor allows the user to pass in a custom list ofPatterns. -
Method Summary
Modifier and TypeMethodDescriptiondecidePolicy(android.net.Uri url) Determines the handling policy for a given URL within a conversation.
-
Constructor Details
-
UnbluPatternMatchingExternalLinkHandler
public UnbluPatternMatchingExternalLinkHandler()Default constructor.
If you use this constructor, the list of patterns that may be opened in the system browser is as follows:^\Qhttps://\E.*^\Qmailto://\E.*^\Qtel:\E.*
-
UnbluPatternMatchingExternalLinkHandler
This constructor allows the user to pass in a custom list ofPatterns. The list overrides the default list.- Parameters:
patternList- A list of patterns to compare links to
-
-
Method Details
-
decidePolicy
Determines the handling policy for a given URL within a conversation. This method checks the URL against a list of predefined URL patterns. If the URL matches any of the patterns, it permits opening the link by returningUnbluExternalLinkHandlingPolicy.OPEN. If the URL does not match any pattern, the link is not allowed to be opened, indicated by returningUnbluExternalLinkHandlingPolicy.BLOCK. This approach allows for fine-grained control over which links can be opened, enhancing security by preventing potentially harmful links from being accessed.- Specified by:
decidePolicyin interfaceUnbluExternalLinkHandler- Parameters:
url- TheUriobject representing the link that was clicked. This parameter is used to extract the string representation of the URL for pattern matching.- Returns:
- The
UnbluExternalLinkHandlingPolicyindicating whether the link should be opened or blocked. If the URL matches a predefined pattern,UnbluExternalLinkHandlingPolicy.OPENis returned, otherwiseUnbluExternalLinkHandlingPolicy.BLOCKis returned.
-