@Override protected void performAction( @NonNull final Context context, @NonNull final Uri uri, @NonNull final UrlHandler urlHandler) throws IntentNotResolvableException { Intents.launchApplicationUrl(context, uri); }
@Override protected void performAction( @NonNull final Context context, @NonNull final Uri uri, @NonNull final UrlHandler urlHandler) throws IntentNotResolvableException { // 1. Parse the URL as a valid deeplink+ if (!"navigate".equalsIgnoreCase(uri.getHost())) { throw new IntentNotResolvableException( "Deeplink+ URL did not have 'navigate' as" + " the host."); } final String primaryUrl; final List<String> primaryTrackingUrls; final String fallbackUrl; final List<String> fallbackTrackingUrls; try { primaryUrl = uri.getQueryParameter("primaryUrl"); primaryTrackingUrls = uri.getQueryParameters("primaryTrackingUrl"); fallbackUrl = uri.getQueryParameter("fallbackUrl"); fallbackTrackingUrls = uri.getQueryParameters("fallbackTrackingUrl"); } catch (UnsupportedOperationException e) { // If the URL is not hierarchical, getQueryParameter[s] will throw // UnsupportedOperationException (see // http://developer.android.com/reference/android/net/Uri.html#getQueryParameter(java.lang.String) throw new IntentNotResolvableException("Deeplink+ URL was not a hierarchical" + " URI."); } if (primaryUrl == null) { throw new IntentNotResolvableException( "Deeplink+ did not have 'primaryUrl' query" + " param."); } final Uri primaryUri = Uri.parse(primaryUrl); if (shouldTryHandlingUrl(primaryUri)) { // Nested Deeplink+ URLs are not allowed throw new IntentNotResolvableException( "Deeplink+ had another Deeplink+ as the " + "'primaryUrl'."); } // 2. Attempt to handle the primary URL try { Intents.launchApplicationUrl(context, primaryUri); makeTrackingHttpRequest(primaryTrackingUrls, context, BaseEvent.Name.CLICK_REQUEST); return; } catch (IntentNotResolvableException e) { // Primary URL failed; proceed to attempt fallback URL } // 3. Attempt to handle the fallback URL if (fallbackUrl == null) { throw new IntentNotResolvableException( "Unable to handle 'primaryUrl' for " + "Deeplink+ and 'fallbackUrl' was missing."); } if (shouldTryHandlingUrl(Uri.parse(fallbackUrl))) { // Nested Deeplink+ URLs are not allowed throw new IntentNotResolvableException( "Deeplink+ URL had another Deeplink+ " + "URL as the 'fallbackUrl'."); } // UrlAction.handleUrl already verified this comes from a user interaction final boolean fromUserInteraction = true; urlHandler.handleUrl(context, fallbackUrl, true, fallbackTrackingUrls); }