iOS
iOS Integration
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
In Certificates, Identifiers & Profiles, select Certificates.
Click the Add button (+)
Under Production, select the “Apple Push Notification service SSL (Sandbox & Production)” checkbox, and click Continue.
Choose an App ID from the App ID pop-up menu, and click Continue. Choose the explicit App ID that matches your bundle ID.
Create a certificate request on your Mac.
Click Choose File.
In the dialog that appears, select the certificate request file (with a .certSigningRequest extension), and click Choose File.
Click Generate.
Click Download.
Follow these steps to export the certificate from Apple web-site to the P12-file:
Open "Keychain access" application
If the certificate hasn't been added to keychain access yet, choose "File" → "Import". Find the certificate file (CER-file) provided by Apple
Choose "Keys" section in "Keychain access" application
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
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
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: Unity Integration.
2. After the DTDAnalytics initialization block call the StartNotificationService
method to activate the Messaging module:
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:
You can specify the necessary display options using the DTDMessaging.IOS.SetNotificationOptions
method.
Example:
A complete example of the notification 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
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 iconDTDNotificationOptionSound
- an option for playing soundDTDNotificationOptionAlert
- an option for displaying an alertDTDNotificationOptionCarPlay
- an option for showing a push notification in CarPlayDTDNotificationOptionCriticalAlert
- 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 onwardsDTDNotificationOptionProvidesSettings
- an option for indicating that the system should show a notification settings button in the application. Available from iOS 12.0 onwardsDTDNotificationOptionProvisional
- an option for sending provisional notifications to the Notification Center without interrupting functioning processes. Available from iOS 12.0 onwardsDTDNotificationOptionAnnunciation
- 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:
Custom sounds
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 here.
When creating a push company, it is important to specify the full name of the sound with file extension (for example, sound.wav).
Last updated