The MarketingCloudSDK.framework uses extensive internal logging to record actions taken by the SDK to informational and diagnostic purposes.

General, default-level logging is enabled at all times. Additionally, the SDK writes error and fault-level logs when conditions occur which must be recorded.

Enable logging using this call. When using version < 8.x enable it after configuration.

Enable logging with a custom log outputter.

Enable logging with a standard log outputter and a log filter. Check Xcode autocompletion for more filtering options.

Clear previously set filtering options

Query the state of debug-level logging using this call.

We send all logging output to Apple’s unified logging system. Read this information using Xcode’s “Devices and Simulators” window or the macOS Console application. When SDK debug logging is enabled, the SDK uses the OS_LOG_TYPE_DEBUG value. Make sure to disable logging in your application for release builds to the Apple App Store.

Review Apple documentation for more information about unified logging.

Device Token

For testing and troubleshooting purposes, retrieve your device token from a running app by calling sfmc_deviceToken() and send the result to yourself via email, alert, or other method.

Send a test push

Test that your app can receive a push directly from APNS (Apple Push Notification Service).

  • Get the push token from the SDK
  • Trigger the APNS API directly from the command line If using a .p8 Auth Key File
  • Trigger the APNS API directly from the command line If using a .p12 cert (Legacy)

Additional Resources

Use this information when testing your app and the device either does not receive messages or receives messages sporadically. Testing the app while connected to a corporate Wi-Fi network could cause issues if your IT team does not correctly configure port accessibility (preventing the test device from receiving messages).

Unblock network ports

Ensure that your network team unblocks the following ports to provide communication between the moble device and APNS servers for MobilePush functionality:

  • TCP port 5223 (used by devices to communicate to the APNS servers)
  • TCP port 2195 (used to send notifications to the APNS servers)
  • TCP port 2196 (used by the APNS feedback service)
  • TCP port 443 (used as a fallback service for Wi-Fi devices when those devices cannot communicate to the APNS service on port 5223)

Add SDK State information to log

For a complete list of information that the SDK has and it’s current state, you can implement getSDKState() as follows:

The SDK will output a JSON string like this: