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
moduleDTDMessagingDelegate
methodsDisplaying 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:
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
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.
The SDK can be found in the devtodev GitHub repository. Download the latest release of the Source code (zip). Unzip the archive and copy the DTDMessaging
folder to the Plugins folder of your project.
If you have a C++ type project, add DTDMessaging
to the list of dependency names in the <module_name>.Build.cs
file of the module in which you plan to use the plugin.
Example:
Add your google-services.json
file to the project's root directory. It will be used to configure notifications during the project-building process.
In the case your Unreal Engine is built from GitHub source code:
Enable notifications in the settings of your project: Edit → Project Settings → iOS → Enable Remote Notifications Support
In the case your Unreal Engine is not built from GitHub source code:
Add the parameter to the engine configuration file (<proj_dir>/Config/DefaultEngine.ini
):
class UDTDMessagingBPLibrary
A class that implements analytic methods.
Header file:
enum class EDTDNotificationActionType : uint8
Notification action type
Header file:
Values:
App = 0
- default value
Url = 1
- external link opening
Share = 2
- share contentc
DeepLink = 2
- an in-app link opening
struct FDTDNotification
Notification data container.
Header file:
struct FDTDNotificationAction
Notification action data container.
Header file:
enum class EDTDIOSNotificationOptions : uint8
iOS only
Push Notification display settings are Bitflags
that are managed by the developer and allow for selecting the method of user notification. It can be altered by the end user.
By default, it has the value: Badge|Sound|Alert
Header file:
Values:
None = 0
- nothing
Badge = 1 << 0
- can display a badge on the app icon
Sound = 1 << 1
- can play a sound
Alert = 1 << 2
- can display an alert
CarPlay = 1 << 3
- can display a push notification on CarPlay
CriticalAlert = 1 << 4
- critical alerts can play a sound even if Do Not Disturb is enabled (critical alerts require a special entitlement issued by Apple). Available from iOS 12 onwards.
AppNotificationSettings = 1 << 5
- this option defines that the system should display a notification settings button in the app. Available from iOS 12.0 onwards.
Provisional = 1 << 6
- an option for sending provisional notifications to the Notification Center without interrupting functioning processes. Available from iOS 12.0 onwards.
Provisional - 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 Provisional setting, the user needs to go to Notification Center settings to allow explicit notifications.
Delegates
Header file:
Delegates:
Notification module initialization:
SetAvailability
A method responsible for enabling/disabling push notifications. When the state changes, it sends an event that includes the availability status (true or false). The availability status flag is stored in the SDK.
GetAvailability
Get the current availability
status flag (true or false):
GetToken
Get a current unique device ID used in the notification system:
SetTokenListener
Set a token listener. The listener will be executed when the SDK updates a unique device ID in the notification system.
SetTokenErrorListener
Set a listener for errors in token reception. The listener will be executed when an error occurs while the SDK updates a unique device ID in the notification system.
SetNotificationReceiveListener
Set a listener for notification reception. The listener will be executed when the SDK receives a notification.
SetInvisibleNotificationReceiveListener
Set a listener for invisible notification reception. The listener will be executed when the SDK receives an invisible notification.
SetNotificationActionListener
Set a listener for notification activation. The listener will be executed when the notification gets activated.
IOSSetNotificationOptions
iOS only
Set notification parameters.
An int32 type value is used as an argument of this method. However, this argument should be calculated by using enumerators of EDTDIOSNotificationOptions
and bitwise OR operator.
The DevToDev.Messaging
package necessary for notifications is available in the NuGet
package manager.
Package Manager UI
Find the DevToDev.Messaging
package using the package manager search engine and click Install. The latest version of the package is recommended.
Package Manager Console
In progress...
For the correct package functioning, add handlers invoke to the Windows.UI.Xaml.Application
class implementation.
Besides, in the UI editor of the Package.appxmanifest file do the following:
Add Background Tasks to the Declarations tab and mark it as System Event. After that enter DevToDev.Background.ToastNotificationBackgroundTask
to the Entry Point field.
Add Background Tasks to the Declarations tab and mark it as Push Notification. After that enter DevToDev.Background.RawNotificationBackgroundTask
to the Entry Point field.
After the SDK has been initialized you can move to initializing messages. To do this, call the method:
It is possible to listen to events from the DevToDev.Messaging
package:
1. Push Token - a string that allows to identify the client on a remote server for sending him customized notifications. For listening the unique Push Token ID issue event, it is necessary to be subscribed to the event:
2. To track the errors related to the unique Push Token ID issue, it is necessary to be subscribed to the event:
Where error is a string value containing information about the error.
3. To handle incoming message data, it is necessary to be subscribed to the following event:
Where messageData
belongs to the IDictionary<string, string>
type and contains data sent from the server together with the message.
4. To handle notification activation events, it is necessary to be subscribed to the event:
Where messageAction
is DevToDev.Messaging.DTDMessageAction
class instance:
Call the method to turn notifications off:
11
Android Push Notifications
Push Notifications on Android are sent with the help of the FCM service.
How to create a project in Firebase and integrate Firebase Services into your application, you can find in .
Next, you need to specify the FCM Server key in the push notifications integration settings panel in the application settings section in devtodev service (App → Settings → Push notifications → Push notifications panel)
To get the FCM Server key, go to the Project Settings of your Android project in the Firebase Console and copy the Server key from the Cloud Messaging tab.
1. If you use Gradle for the applications build, add mavenCentral()
into gradle.build file of your application and specify the following relationship in dependencies block:
2. To the app manifest add the following:
3. To add a user icon to your push notification and change its color, add the following strings to the manifest file code:
To add a large user icon to your push notifications, add:
Example:
4. After the DTDAnalytics
initializer, add the DTDMessaging
initializer.
Example:
5. Subscribe a DTDPushListener
to receive information about the DTDMessaging
functioning.
Example:
6. Call the DTDMessaging.startPushService()
method to activate the Messaging module.
DTDMessaging
moduleDTDPushListener
Interface MethodsDTDPushMessage
).DTDActionButton
)Member | Type | Description |
---|---|---|
Member | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
Arguments | Type | Description |
---|---|---|
For the DevToDev.Messaging
package functioning you need to have the main DevToDev.Analytics
package installed. Initialize the SDK before initializing messages. You can read about it in more detail in the .
The Messaging module is available as an AAR (recommended) and JAR library. The library is available in the MavenCentral and .
Object
Type
Description
startPushService
Method responsible for activating push notifications:
Requests permission from the user to receive Push Notifications
Sends a pushToken and the current state isAllowed
apnsToken
Data?
Getter giving the current pushToken, represented by a Data
apnsTokenString
String?
Getter giving the current pushToken, represented by a String
delegate
DTDMessagingDelegate?
Property for assigning a delegate to handle events from the SDK
pushNotificationsOptions
DTDNotificationOptions
Configuring the display of Push Notifications, is an OptionSet
, is set by the developer to select the method for notifying the user. May be changed by the end user.
By default it has the following value: [.DTDNotificationOptionBadge, .DTDNotificationOptionSound, .DTDNotificationOptionAlert]
Delegate method
Description
didFailToRegisterForRemoteNotifications
(with error:
Error
)
The method is called when an error occurs at the time of receiving a pushToken, represented by the Error
base class.
didOpenRemoteNotification
(with message:
DTDMessage
, and buttonClicked:
DTDActionButton?
)
The method is called when a remote push notification is opened by an end user. A DTDMessage
object and an optional DTDActionButton
object are passed.
didReceiveForegroundNotification
(with message:
DTDMessage
)
The method is called when a remote push notification is received when the application is in the Foreground state. The DTDMessage
object is passed.
didReceiveInvisibleNotification
(with message:
DTDMessage
)
The method is called when an invisible remote push notification is received. The DTDMessage
object is passed.
didRegisterForRemoteNotifications
(with deviceToken:
Data
)
The method is called in case the pushToken
successfully arrives; represented by a Data.
Property
Type
Description
payload
[AnyHashable:Any]
Full information sent using remote push notification.
actionType
DTDActionType
Property returning the enum DTDActionType value. Possible values:
App
- default value
Url
- open an external link
Share
- share content
Deeplink
- open a link inside the application
actionString
String?
Property returning an optional action identifier.
badge
Int
The value that is passed to display a badge on the application icon.
category
String?
Property returning an optional identifier of a push notification category
Property
Type
Description
actionType
DTDActionType
Property returning the enum DTDActionType value. Possible values:
App
- default value
Url
- open an external link
Share
- share content
Deeplink
- open a link inside the application
actionString
String?
Property returning an optional action identifier.
buttonId
String
Property returning the identifier of the pressed button.
text
String
Property returning the text of the pressed button.
Value
Description
DTDNotificationOptionBadge
display a badge on the application icon
DTDNotificationOptionSound
play sound
DTDNotificationOptionAlert
display an alert
DTDNotificationOptionCarPlay
display push notification in CarPlay
DTDNotificationOptionCriticalAlert
play sound for critical notifications regardless of the “Do Not Disturb” setting (Critical alerts require special permission from Apple.) Available since iOS 12.0
DTDNotificationOptionProvidesSettings
an option specifying that the system should display a button for notification settings in the application. Available since iOS 12.0
DTDNotificationOptionProvisional
pre-send notifications to the Action Center without interrupting work. Available since iOS 12.0
DTDNotificationOptionAnnouncement
for Siri to automatically read messages through AirPods. Available since iOS 13.0
ActionType
EDTDNotificationActionType
Тип действия уведомления
ActionString
FString
Идентификатор действия уведомления
Data
TMap<FString, FString>
Данные уведомления
ActionType
EDTDNotificationActionType
Тип действия уведомления
ActionString
FString
Идентификатор действия уведомления
ButtonId
FString
Идентификатор нажатой кнопки
ButtonText
FString
Текст нажатой кнопки
ButtonIcon
FString
Иконка нажатой кнопки
IsBackground
bool
Режим открытия приложения кнопкой
onResult
FDTDMessagingDynamicBoolParamsDelegate
FDTDMessagingBoolParamsDelegate
Callback
onResult
FDTDMessagingDynamicStringParamsDelegate
FDTDMessagingStringParamsDelegate
Callback.
listener
FDTDMessagingDynamicStringParamsDelegate
FDTDMessagingStringParamsDelegate
Listener.
listener
FDTDMessagingDynamicStringParamsDelegate
FDTDMessagingStringParamsDelegate
Listener.
listener
FDTDMessagingDynamicNotificationParamsDelegate
FDTDMessagingNotificationParamsDelegate
Listener.
listener
FDTDMessagingDynamicNotificationParamsDelegate
FDTDMessagingNotificationParamsDelegate
Listener.
listener
FDTDMessagingDynamicNotificationActionParamsDelegate
FDTDMessagingNotificationActionParamsDelegate
Listener.
options
int32
Options.
Object | Description |
| The main object for push notification initialization. |
| The push notification initialization method. |
| The push notification activation method. It passes the |
| A property responsible for the activation/deactivation of push notifications. Functions as a getter (describes the current state) and a setter (sets the current state). When the state transitions, it sends a pt with The |
| A method of passing a user intent to the SDK using PushMessage. |
Written in the manifest file
| Sets a small custom user icon. |
Written in the manifest file
| Sets a color of the small custom user icon. |
Written in the manifest file
| Sets a large custom user icon. |
| Returns a push notification registration token ( |
| Used to pass the push notification to the FirebaseMessagingService if it was implemented by the client but not by the SDK. |
| ( |
DTDPushListener Interface Methods | Description |
| Returns a push notification registration token ( |
onPushServiceRegistrationFailed(String error) | Returns errors during push notification registration. |
| Returns a directory with data for improving your push notifications. |
| Returns |
Property | Type | Description |
| Map<String, String> | Complete information sent with the use of a remote push notification. |
| Int | The notification ID used in the devtodev system. |
| String? | Returns the selected message title or app name if the former is unavailable. |
| String? | The text body. |
| String? | A group of messages. |
| Uri? | Returns the storage path of an audio file. |
| String? | The notification sound name. |
| String? | The notification tag. |
| String? | The notification color. |
| String? | The notification banner if specified. |
| DTDActionType | The property that returns an enum’s DTDActionType value. Possible values:
|
| String? | The property that returns an optional action ID. |
| Int | The icon resource identifier specified by the user (if specified). |
| String? | The large notification icon name. |
| List<DTDActionButton> | The list of action buttons used in the push notification. |
| Boolean | Specifies whether the push notification was sent using the devtodev API. |
Property | Type | Description |
| String? | The property that returns the tapped button ID. |
| String? | The property that returns the optional action ID. |
| DTDActionType | The property that returns an enum’s Possible values:
|
| String? | The property that returns the button’s icon name. |
| Boolean | The button-click app open mode. |
| String? | The property that returns the text of the tapped button. |