iOS
Last updated
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):
CocoaPods is the easiest way to add devtodev into your iOS project.
1. Firstly, install CocoaPods using:
2. In the project directory execute the command:
3. In the created Podfile add the dependency:
4. Finally, run the command in your Xcode project directory:
CocoaPods should download and install the devtodev library, and create a new Xcode workspace. Open this workspace in Xcode.
To connect the module for processing push notifications, you need to:
1. Download the latest devtodev SDK from the repository
2. Add DTDAnalytics.xcframework
to the project (check Do Not Embed)
The DTDMessaging plugin will not work without the DTDAnalytics main analytics plugin.
3.Add DTDMessaging.xcframework to the project (check Do Not Embed)
4. In the Xcode project settings, open the tab, and add: "Push Notifications" and "Background Modes" respectively
5. In the "Background Modes" section, enable "Remote notifications"
6. Add initialization to didFinishLaunchingWithOptions
method:
7. To handle SDK delegate methods, you need to add the implementation of the DTDMessagingDelegate
protocol
The DTDMessaging
module provides support for notifications with attachments. These notifications are available since iOS 10. Attachments support images, animated gifs and videos. To use this function, you will need to create a “Notification Service Extension“, for this create a new target in your application settings:
Open Xcode (File -> New -> Target). Select Notification Service Extension.
The next step is to modify the Notification Extension
class as follows:
Delete all auto-generated code.
Inherit Notification Extension
class from DTDMediaAttachmentExtension
Example:
DTDMessaging
moduleObject | Type | Description |
| Method responsible for activating push notifications:
| |
| Data? | Getter giving the current pushToken, represented by a Data |
| String? | Getter giving the current pushToken, represented by a String |
| DTDMessagingDelegate? | Property for assigning a delegate to handle events from the SDK |
| DTDNotificationOptions | Configuring the display of Push Notifications, is an By default it has the following value: |
DTDMessagingDelegate
methodsDelegate method | Description |
| The method is called when an error occurs at the time of receiving a pushToken, represented by the |
| The method is called when a remote push notification is opened by an end user. A |
| The method is called when a remote push notification is received when the application is in the Foreground state. The |
| The method is called when an invisible remote push notification is received. The |
| The method is called in case the |
Property | Type | Description |
| [AnyHashable:Any] | Full information sent using remote push notification. |
| DTDActionType | Property returning the enum DTDActionType value. Possible values:
|
| String? | Property returning an optional action identifier. |
| Int | The value that is passed to display a badge on the application icon. |
| String? | Property returning an optional identifier of a push notification category |
Property | Type | Description |
| DTDActionType | Property returning the enum DTDActionType value. Possible values:
|
| String? | Property returning an optional action identifier. |
| String | Property returning the identifier of the pressed button. |
| String | Property returning the text of the pressed button. |
Displaying push notifications in Foreground state is available since iOS 10.0.
By default, according to Apple Push Notification Guidelines, the display of push notification in the Foreground state is disabled. In order to set the display method, you must:
Assign delegate for UNUserNotificationCenter
Or pass a parameter in the push notification constructor (_fg = 1
). In this case, the display method will be formed from the Notification settings.
Or delegate the system method userNotificationCenter willPresent notification
. In this case, the display properties will be taken from the developer.
An example of a delegated method implementation:
It is an OptionSet
that is used to pass push notification authorization and set up interactions with users.
The user can change the allowed parameters at any time in the notification settings.
Possible values:
Value | Description |
| display a badge on the application icon |
| play sound |
| display an alert |
| display push notification in CarPlay |
| play sound for critical notifications regardless of the “Do Not Disturb” setting (Critical alerts require special permission from Apple.) Available since iOS 12.0 |
| an option specifying that the system should display a button for notification settings in the application. Available since iOS 12.0 |
| pre-send notifications to the Action Center without interrupting work. Available since iOS 12.0 |
| for Siri to automatically read messages through AirPods. Available since iOS 13.0 |
DTDNotificationOptionProvisional
- Provisional push notifications appear in the user's Notification Center, but not on the lock screen. This type of push notification does not have to be explicitly allowed by the user. Start submitting them as soon as the user installs and runs your application. However, the user can also opt in/opt out of notifications, but they will need to do it explicitly.
This setting is used to prevent receiving push notification permission requests at the start, which is intrusive and most users refuse to receive them.
It is also important that when using the DTDNotificationOptionProvisional
setting, the user will be able to subscribe to explicit notifications only from the notification center settings.
DTDMediaAttachmentExtension
To handle the application attitude to displaying push notifications, you need to add a Notifications service Extension. And inherit NotificationService
from DTDMediaAttachmentExtension
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).
DTDMessaging automatically swizzles notification tracking and APNS-token usage methods by default. If you want to disable the function, add the flag DTDMessagingSwizzlingEnabled
(boolean) in the app’s Info.plist
file and set it to NO (0). However, if you disable notification swizzling, you will need additional integration for accurate analytics:
For sending APNS-token to DTDMessaging:
For sending information about the application:
Note: If you disable automatic notification swizzling, DTDMessagingDelegate
methods will not be called.