Handle URLs
The SDK doesn’t automatically present URLs from these sources:
- CloudPages URLs from push notifications
- OpenDirect URLs from push notifications
- CloudPages URLs from inbox messages using the built-in
UITableViewdelegate
To handle URLs from these sources, follow these steps.
- Implement the
URLHandlingDelegateprotocol in your app. - Use
setURLHandlingDelegatemethod to set a delegate for the protocol. - Next, you’re prompted to implement the protocol method
sfmc_handleURL:type:
When an OpenDirect or CloudPages push notification is received, the SDK passes a NSURL value to sfmc_handleURL:type:. This value contains the push notification or inbox message, and includes the URL. A type value also reflects the source of the URL, which is either SFMCURLTypeCloudPages or SFMCURLTypeOpenDirect.
If the development language is Swift, the class that implements the URLHandlingDelegate must be compatible with Objective-C. Prefix the class with @objc and extend NSObject, as shown in this example.