Skip to content

Trusted Domains Security

Ivan Bilobrk edited this page Nov 16, 2026 · 1 revision

Trusted Domains Security

Available since version 10.3.0

The Trusted Domains feature is an optional security enhancement that allows you to restrict which URLs can be opened by the Mobile Messaging SDK. This helps protect your users from potentially malicious URLs that could be sent through push notifications.

Table of Contents

Overview

A push message or a Mirror push notification can contain an on-tap action which opens a URL in the in-app webView or in the device browser. When trusted domains are configured, the SDK will only open those URLs that match the specified domains. URLs from untrusted domains will be blocked and logged as warnings.

Key Benefits:

  • Protection against malicious URLs
  • Control over which domains your app can navigate to
  • No breaking changes - completely optional feature
  • Backward compatible with existing implementations

Configuration

Configure trusted domains during plugin initialization using the trustedDomains parameter of Configuration:

import 'package:infobip_mobilemessaging/infobip_mobilemessaging.dart';
import 'package:infobip_mobilemessaging/models/configurations/configuration.dart';

await InfobipMobilemessaging.init(Configuration(
    applicationCode: '<Your Application Code>',
    iosSettings: IOSSettings(
        notificationTypes: ['alert', 'badge', 'sound'],
    ),
    trustedDomains: ['example.com', 'yourdomain.com', 'api.trusted.org'],
));

Parameters:

  • trustedDomains: List<String> of domains that should be trusted
  • Domain format: 'example.com', 'subdomain.example.com', etc. Provide only the host name in lowercase, without scheme (https://), port or path.

The plugin passes the trusted domains to the native iOS and Android SDKs, which perform the validation. The trusted domains are stored on the device, so they are also applied to notifications received while the application is not running, before init is called again. Calling init without trustedDomains (or with an empty list) removes the stored domains.

How It Works

The SDK validates domains for the following URL types:

  • WebView URLs (webViewUrl): URLs opened in the in-app webView
  • Browser URLs (browserUrl): URLs opened in an external browser

The validation happens before opening the URL. If a URL's domain is not trusted, the SDK will:

  1. Block the URL from opening
  2. Log a warning message
  3. Continue normal execution without the URL action

Domain Matching Rules

Exact and Subdomain Match

// Trusted domain: "example.com"
// ✅ Matches: https://example.com/page
// ✅ Matches: https://api.example.com/endpoint
// ✅ Matches: https://cdn.example.com/image.jpg
// ✅ Matches: https://www.example.com/home

Partial Match Prevention

// Trusted domain: "example.com"
// ❌ Does not match: https://badexample.com/malicious
// ❌ Does not match: https://example.com.evil.org/phishing

What URLs Are Affected

URLs That Are Validated

  • URLs from the push notification webViewUrl field (webView action)
  • URLs from the push notification browserUrl field (browser action)

URLs That Are NOT Validated

Note: To open a deep link or another non-HTTP/HTTPS URL (e.g. myapp://, tel:, mailto:), use the deeplink action. When trusted domains are configured, such URLs sent as a webView or browser action may be blocked, because they have no domain to match. The exact behavior differs between platforms and is not guaranteed.

Backward Compatibility

The trusted domains feature is completely backward compatible:

  • Without configuration (trustedDomains omitted or null): All URLs work exactly as before
  • With empty list: trustedDomains: [] - All URLs are allowed
  • With domains: Only specified domains are allowed

Examples

URL Behavior Examples

// Configuration
trustedDomains: ['example.com', 'trusted.org']

// ✅ These URLs will be opened:
// https://example.com/page
// https://api.example.com/data
// https://www.example.com/home
// https://trusted.org/content

// ❌ These URLs will be blocked:
// https://malicious.com/phishing
// https://untrusted.net/spam
// https://fake-example.com/scam

// ✅ These deeplinks will still work when sent as the deeplink action (not validated):
// myapp://open-screen
// myapp://deeplink/ProductScreen

Logging

When URLs are blocked, the SDK logs warning messages, for example:

URL domain is not trusted and will not be opened: https://malicious.com/phishing
WebView URL domain is not trusted and will not be opened: https://malicious.com/phishing
Browser URL domain is not trusted and will not be opened: https://untrusted.net/spam

These logs help with debugging and monitoring security events in your application. See How to enable logging.

Related Documentation

Clone this wiki locally