LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
    • Acquisition Example
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • Platform integration
  • Module initialization
  • External interface of the DTDMessaging module for iOS platform
  • IDTDPushListener interface
  • Class for receiving Notification data (DTDPushMessage). Main class properties
  • Class for handling buttons clicked in the notification (DTDActionButton)
  • DTDNotificationOptions
  • XCODE build
  • Notification with Attachments
  • Custom sounds

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 2.0+
  3. Push notifications
  4. Unity

iOS

iOS Integration

PreviousAndroidNextWindows (UWP/WSA)

Last updated 18 days ago

Was this helpful?

Platform integration

Creating a Universal Push Notification Client SSL Certificate

You use Member Center to generate a push notification client SSL certificate that allows your notification server to connect to the APNs. Each App ID is required to have its own client SSL certificate. The client SSL certificate Member Center generates is a universal certificate that allows your app to connect to both the development and production environments.

Only a team agent or admin can generate Apple Push Notification service SSL certificates.

To generate a universal client SSL certificate

  1. In , select Certificates.

  2. Click the Add button (+)

  3. Under Production, select the “Apple Push Notification service SSL (Sandbox & Production)” checkbox, and click Continue.

  4. Choose an App ID from the App ID pop-up menu, and click Continue. Choose the explicit App ID that matches your bundle ID.

  5. Create a certificate request on your Mac.

  6. Click Choose File.

  7. In the dialog that appears, select the certificate request file (with a .certSigningRequest extension), and click Choose File.

  8. Click Generate.

  9. Click Download.

Follow these steps to export the certificate from Apple web-site to the P12-file:

  1. Open "Keychain access" application

  2. If the certificate hasn't been added to keychain access yet, choose "File" → "Import". Find the certificate file (CER-file) provided by Apple

  3. Choose "Keys" section in "Keychain access" application

  4. Choose a personal key associated with your iPhone developer certificate. Personal key is identified by open certificate associated with it "iPhone developer: ". Choose "File" → Export objects. Save key as .p12

  5. You'll be suggested to create a password which is used when you need to import the key to another computer

Upload the certificate to the site

Upload the .p12-file into Integration section of application settings panel (Settings -> Push Notifications):

Module initialization

2. After the DTDAnalytics initialization block call the StartNotificationService method to activate the Messaging module:

DTDMessaging.IOS.StartNotificationService();

Optional:

You can listen to basic notification module events. To do this, create a class that implements the IDTDPushListener interface and pass it to the DTDMessaging.IOS.SetPushListener method.

Example:

public class MyPushListener : IDTDPushListener
{
    public void OnPushServiceRegistrationSuccessful(string deviceId)
    {
        Debug.Log(deviceId);
    }

    public void OnPushServiceRegistrationFailed(string error)
    {
        Debug.Log(error);

    }

    public void OnPushNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnInvisibleNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnPushNotificationOpened(DTDPushMessage pushMessage, DTDActionButton actionButton)
    {
        Debug.Log(pushMessage.ToString());
        Debug.Log(actionButton.ToString());
    }
}

You can specify the necessary display options using the DTDMessaging.IOS.SetNotificationOptions method.

Example:

DTDMessaging.IOS.SetNotificationOptions(DTDNotificationOptions.Alert | DTDNotificationOptions.Badge | DTDNotificationOptions.Sound);

A complete example of the notification module initialization:

public class MyPushListener : IDTDPushListener
{
    public void OnPushServiceRegistrationSuccessful(string deviceId)
    {
        Debug.Log(deviceId);
    }

    public void OnPushServiceRegistrationFailed(string error)
    {
        Debug.Log(error);

    }

    public void OnPushNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnInvisibleNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnPushNotificationOpened(DTDPushMessage pushMessage, DTDActionButton actionButton)
    {
        Debug.Log(pushMessage.ToString());
        Debug.Log(actionButton.ToString());
    }
}

public class NotificationExample : MonoBehaviour
{
    private const string APP_KEY = "***************"
    void Start()
    {
        DTDAnalytics.Initialize(APP_KEY);
        DTDMessaging.IOS.SetNotificationOptions(DTDNotificationOptions.Alert | DTDNotificationOptions.Badge | DTDNotificationOptions.Sound);
        DTDMessaging.IOS.SetPushListener(new PushListener());
        DTDMessaging.IOS.StartNotificationService();
    }
}

External interface of the DTDMessaging module for iOS platform

Methodes
Description

void DTDMessaging.IOS.StartPushService()

The method responsible for push notification activation:

  • Requests user permission to receive push notifications

  • Sends push token and current state isAllowed

void DTDMessaging.IOS.GetToken(Action<string> onGetToken)

The method that returns current push token to onGetToken callback

DTDMessaging.IOS.SetPushListener(IDTDPushListener listener)

The method for assigning a push notification event listener

void DTDMessaging.IOS.PushNotificationsOptions(uint options)

options is responsible for setting up the display of Push Notifications. It is set by the developer to select the method of notifying the user. It can be changed by the end-user.

By default, it has the value:

[.DTDNotificationOptionBadge, .DTDNotificationOptionSound, .DTDNotificationOptionAlert]

void DTDMessaging.IOS.PushIsAllowed (bool isAllowed )

The method is responsible for enabling / disabling the ability to send a push notification to the user from devtodev.

void DTDMessaging.IOS.GetPushState(Action<bool> onGetPushState)

The method that returns the push module state to onGetPushState callback

IDTDPushListener interface

Delegate method
Description

void OnPushServiceRegistrationSuccessful (string deviceId);

The method is called if a push token is successfully received, represented by a string.

void OnPushServiceRegistrationFailed (string error);

The method is called if at the time of receiving a pushToken errors occur. It passes the text of the error that occurred

void OnInvisibleNotificationReceived (DTDPushMessage message);

The method is called when an invisible remote push notification is received. The DTDPushMessage object is passed

void OnPushNotificationReceived (DTDPushMessage message);

The method is called when a remote push notification is received while the application runs in the Foreground state. The DTDPushMessage object is passed.

void OnPushNotificationOpened (DTDPushMessage pushMessage, DTDActionButton actionButton);

The method is called when the end-user opens a remote push notification. The DTDPushMessage object and the optional DTDActionButton object are passed.

Class for receiving Notification data (DTDPushMessage). Main class properties

Property
Description

IDictionary<string,string> GetData():

Complete information passed with the push notification.

DTDActionType ActionType:

The property that returns the value of enum’s DTDActionType.

Possible values:

App - app open

Url - external link open

Share - share content

Deeplink - open a link that leads straight to a specific in-app location

string ActionString

The property that returns an optional action identifier

IDictionary<string,string> AdditionalData()

Additional data sent to push notification

Class for handling buttons clicked in the notification (DTDActionButton)

Property
Description

DTDActionType ActionType

The property that returns the value of enum’s DTDActionType.

Possible values:

App - app open

Url - external link open

Share - share content

Deeplink - open a link that leads straight to a specific in-app location

string ActionString

The property that returns an optional action identifier

string ButtonId

The property that returns the ID of the clicked button

string ButtonText

The property that returns the text of the clicked button

DTDNotificationOptions

It is an OptionSet used for push notification authorization and configuration interaction with users.

Attention: The user can change the allowed parameters in the notification settings at any time.

Possible values:

  • DTDNotificationOptionBadge - an option for displaying a badge on the application icon

  • DTDNotificationOptionSound - an option for playing sound

  • DTDNotificationOptionAlert - an option for displaying an alert

  • DTDNotificationOptionCarPlay - an option for showing a push notification in CarPlay DTDNotificationOptionCriticalAlert - an option for playing sound for critical alerts regardless of whether “do not disturb” is on or not. (Critical alerts require special permission from Apple). Available from iOS 12.0 onwards

  • DTDNotificationOptionProvidesSettings - an option for indicating that the system should show a notification settings button in the application. Available from iOS 12.0 onwards

  • DTDNotificationOptionProvisional - an option for sending provisional notifications to the Notification Center without interrupting functioning processes. Available from iOS 12.0 onwards

  • DTDNotificationOptionAnnunciation - an option for Siri to automatically read messages through AirPods. Available from iOS 13.0 onwards

Attention: DTDNotificationOptionProvisional - Provisional push notifications are shown in the User Notification Center but not on the lock screen. This type of push notification doesn’t require an explicit opt-in from the user. You can start sending them as soon as the user installs and launches your app. However, the user can also explicitly enable/disable your notifications.

Use this setting to avoid the permission request on app launch because it is seen as intrusive, and most users opt-out of it.

It’s also important that when using the DTDNotificationOptionProvisional setting, the user needs to go to Notification Center settings to allow explicit notifications.

XCODE build

After the build, open the signing and capabilities tab in the XCode project settings and add "Push Notifications" and "Background Modes" (tick the box against Remote notifications).

Notification with Attachments

The framework provides support for iOS 10+ notification attachments, such as images, animated gifs, and video. In order to take advantage of this functionality, you will need to create a notification service extension alongside your main application. Create a new iOS target in Xcode (File -> New -> Target) and select the Notification Service Extension type. ​In the Member Center, a Push Notifications service will appear as Configurable (not Enabled) until you create a client SSL certificate.

The framework supports notification attachments: images, audio, and video. To enable the functionality, you need to complete several steps:

  • Create a new iOS target in Xcode (File -> New -> Target) and select the Notification Service Extension

  • Set language to ‘Swift’

  • In the next window, click ‘Activate’

  • In the ‘Build Settings’ tap, change 'Architectures’ to ‘Standard Architecture (arm64, armv7)

  • Open the ‘Frameworks’ folder in your project, find the ‘DTDMessagingUnity’ framework and tick the box of your target in the ‘Target Membership’ section

  • In the NotificationService class (in the folder named after your target), replace the code with the following:

import UserNotifications
import DTDMessagingUnity

class NotificationService: DTDMediaAttachmentExtension {

}

Custom sounds

When creating a push company, it is important to specify the full name of the sound with file extension (for example, sound.wav).

1. For the Messaging module to function you need the basic Analytics package. Before the notification initialization, you need to initialize the SDK. More about it you can read here: .

To use custom sounds for push notifications, you need to copy the necessary sound files to the Libraries folder of your Xcode project. You can read more about supported formats .

Unity Integration
here
Certificates, Identifiers & Profiles