iOS
iOS Integration
Last updated
iOS Integration
Last updated
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.
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 .p12-file into Integration section of application settings panel (Settings -> Push Notifications):
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:
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:
Methodes | Description |
---|---|
| The method responsible for push notification activation:
|
void DTDMessaging.IOS.GetToken(Action<string> onGetToken) | The method that returns current push token to |
| The method for assigning a push notification event listener |
| 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:
|
| The method is responsible for enabling / disabling the ability to send a push notification to the user from devtodev. |
| The method that returns the push module state to |
Delegate method | Description |
---|---|
| The method is called if a push token is successfully received, represented by a string. |
| The method is called if at the time of receiving a pushToken errors occur. It passes the text of the error that occurred |
| The method is called when an invisible remote push notification is received. The |
| The method is called when a remote push notification is received while the application runs in the Foreground state. The |
| The method is called when the end-user opens a remote push notification. The |
Property | Description |
---|---|
| Complete information passed with the push notification. |
| The property that returns the value of enum’s Possible values:
|
| The property that returns an optional action identifier |
| Additional data sent to push notification |
Property | Description |
---|---|
| The property that returns the value of enum’s Possible values:
|
s | The property that returns an optional action identifier |
| The property that returns the ID of the clicked button |
| The property that returns the text of the clicked button |
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.
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).
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:
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).