Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Integration of push notifications on Android and iOS using devdodev SDK for Adobe Air
Push Notifications are availible only for iOS and Android.
Go to Firebase console and then to your project or create a new one.
Current project:
New project:
Save the google-services.json file and add it to your app so that it is placed inside the Assets folder in a ready .apk file. If you use Flash Builder IDE simply copy it in the root folder, Flash Builder will do the rest for you.
Update Adobe Air SDK. Pay attention that version of the Adobe Air SDK should be at least 22.0, otherwise FCM classes will not be imported into your project. However, you still can use Analytics, but application will not be able to accept Push Notifications.
Add dependencies to your project. These libraries are located in the same archive with com.devtodev.SDK.ane extension in the dependencies folder. These extensions contain firebase, gps и android-support libraries Java, that are used for sending Push Notifications. If you have already imported firebase-auth, firebase-common, firebase-iid, firebase-messaging, play-services-auth, play-services-base, play-services-basement, support-v4 or they are included in other extensions, you don't need to import them again. In any case, we recommend to use data from the library of a version not lower than 25. Add the following to the manifest file of your app:
Add the following to your application's manifest:
Add the following imports to your source:
Add the push notifications initialization before the DevToDev.init(appKey:String, appSecret:String) method was called:
onPushToken, onPushTokenFailed, onPushReceived and onPushOpened are the functions that take following arguments:
1. Proceed to Setting -> PUSH NOTIFICATIONS:
2. Insert the previously received Server API Key to the API Key field in Push notifications section.
3. If the Server API Key is correct, you will see the following result
Open PUSH NOTIFICATIONS section and click on 'Add new campaign' button
Fill in campaign name, select an app for delivery
Choose user group to send a message. You can choose existing segment or create a new one.
Enter notification details
Make some tests and correct the message if it's required
Schedule the delivery
That's it!
You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.
To enable Push Notifications, please perform the following actions:
Add the application to your space in devtodev system
Generate Developer or Production Certificate for the application and get Private key file (.p12) on its basis
Submit the data to the application settings in devtodev system
Integrate devtodev SDK to the application (see the “SDK integration” division to learn more about integrating and initializing devtodev SDK)
Add several lines of the code to switch in the push notification to the SDK
Create a campaign for sending push notifications in “Push” section
At first, you need to generate Certificate Signing Request. We have already done it, so you can just click "Continue".
At next step you need to upload the CSR to the Apple server. Choose the CSR-file and click "Generate".
You'll need to repeat this process to generate the Production Certificate when your app will be ready for release. All steps are the same.
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 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.
Convert Apple certificate file to the PEM-file. Start the following command-line operation from bin catalog OpenSSL.
Convert personal key from Mac OS keychain to the PEM-key:
Now you are able to create P12-file using PEM-key and iPhone developer certificate:
If you are using key from Mac OS keychain than choose PEM-version created at previous step.
Otherwise you can use OpenSSL key for Windows OS.
Upload the .p12-file into Integration section of application settings panel (Settings -> PUSH NOTIFICATIONS):
After the certificates has been generated you can start to integrate Push SDK into you app.
Add the following to your application's manifest. Don't forget that the minimum supported version is iOS 7:
Attention! If you use Production Certificate for signing application package, don't forget to change "development" value to "production".
Add the following imports to your source:
Add the push notifications initialization before the DevToDev.init(appKey:String, appSecret:String) method was called:
onPushToken, onPushTokenFailed, onPushReceived and onPushOpened are the functions that take following arguments:
Compile and run the app. You will need a device, because simulator does not support push notifications.
Xcode will automatically choose new provisioning profile. If an error occurred during the launch make sure that there is a correct profile set in the Code Signing Identity. You'll be asked to confirm push notifications. An app will request permission only once, if user confirm it - notifications will be accepted otherwise he wont get any push messages from your app. User can change it in device settings.
1. Open PUSH NOTIFICATIONS section and click on "Add new campaign" button.
2. Fill in campaign name
You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.
3. Choose user group to send a message. You can choose existing segment or create a new one.
4. Enter notification details
5. Test push notification (or skip this step)
6. Confirm push gateway
7. Schedule the delivery
8. That's it!
Open "Keychain access" utility (Launchpad → Other) and choose "Request a Certificate From a Certificate Authority" option.
Fill in all requied fields in Certificate Assistant window, set flag an "Saved on disk" item and click "Continue". Save the file.
Log in at iOS Provisioning Portal. Open "App IDs" section, choose your app and click "Edit".
Activate "Push Notifications" option and click on "Create Certificate"
Certificate generation takes just a few seconds. After generation is finished click "Download" and then "Done".
Android Push Notifications
Push Notifications on Android are sent with the help of the FCM service. To work with it, two keys are required: a client and server key. If you have a project, move on to the second part of this article.
Add a new project to the Firebase console.
Fill in the name and country of your project.
Congratulations, the project has been created! Now you need to indicate the package name of your Android app.
Go to the settings of your Android project.
Remember or copy Server key and Sender ID from the Cloud Messaging tab. You will need them to integrate push notifications and create push campaigns.
Download the generated by google-service.json file and add it to the project.
The Google services plugin for Gradle loads the google-services.json file that you just downloaded. Modify your build.gradle files to use the plugin.
Project-level build.gradle (<project>/build.gradle):
App-level build.gradle (<project>/<app-module>/build.gradle):
In Activity (where the SDK initializes) add the push notifications initialization and the listener of push notifications processing.
Optional. To set the custom icons to be shown in push-notification on the SDK part, use the following methods: To set the small icon:
To set the default color of the small icon:
To set the large icon:
Use resources of your app. For example, R.drawable.ic_launcherIcons which set in the push-notification wizard have priority over the icons which set in these methods.
In case you use several push notifications services or would like to use your own implementation of FirebaseMessagingService, please add the call of the method for displaying messages sent from the devtodev system:
For example:
1. Go to Firebase console and then to your project settings. On the Cloud messaging tab get the Firebase Cloud Messaging token of your project.
2. Proceed to Settings of your app in devtodev.
3. Go to Integration page and insert the previously received Firebase Cloud Messaging token to the FCM token field in Push notifications section.
4. If the Firebase Cloud Messaging token is correct, you will see the following result
Open PUSH NOTIFICATIONS section and click on 'Add new campaign" button
Fill in campaign name, select an app for delivery*
Choose user group to send a message. You can choose existing segment or create a new one
Enter notification details
Make some tests and correct the message if it's required
Schedule the delivery
That's it!
You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.
Integration of push notifications on Windows 8.1 and Windows 10
To enable Push Notifications you will have to perform the following actions:
Add the application to your space in devtodev system
Activate Windows Messaging Service ang get SID and Client Secret values
Add SID and Client Secret to the application integration settings in devtodev system
Integrate devtodev SDK to the application (see the "SDK integration" section to learn more how to integrate and initialize devtodev SDK)
Add several lines of the code to switch on the push notification in the SDK
Create a campaign for sending push notifications in "Push" section
Go to the application settings in your Windows Store dashboard
Open Push Notifications submenu in Services menu
Go to Live Services site:
"Package SID" and "Client secret" will be your SID and Client Secret strings respectively
Integrate devtodev SDK to your project. Even if you don't need devtodev analytics in your app, you should call DevToDev.SDK.Initialize(string appKey, string appSecret).
Add the following source after DevToDev.SDK.Initialize(string appKey, string appSecret) is called:
The PushType can have one of the following values:
The control of the current value of a badge. When an app is launched the current value of a badge is reset to zero by default. In order to disable automatic resetting to zero and manually control the value of a badge use the following methods:
Attention! There is a difference in the implementation of the elements mentioned below for Windows 8.1+ and Windows 10+ projects.
Windows 8.1+: Put the following source in your Application class (usually it is App.xaml.cs file) at the end of the OnLaunched(LaunchActivatedEventArgs e) function. For Example:
Windows 10+: Put the following source in your Application class (usually it is App.xaml.cs file) at the end of the OnLaunched(LaunchActivatedEventArgs e) and OnActivated(IActivatedEventArgs args) functions. For Example:
1. Proceed to Settings of your app.
2. Go to PUSH NOTIFICATIONS page in Settings and insert the previously received Package SID and Client secret to appropriate fields in Push notifications section.
3. If the Package SID and Client secret are correct, you will see the following result:
Open PUSH NOTIFICATION section and click on "Add new campaign" button
Fill in campaign name, select an app for delivery*
Choose the user group to send a message. You can choose existing segment or create a new one
Enter toast or tile details
Schedule the delivery
That's it!
*Attention! You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.
Integration with iOS push notification service
To enable Push Notifications, please perform the following actions:
Add the application to your space in devtodev system
Generate Developer or Production Certificate for the application and get Private key file (.p12) on its basis
Submit the data to the application settings in devtodev system
Integrate devtodev SDK to the application (see the “SDK integration” division to learn more about integrating and initializing devtodev SDK)
Add several lines of the code to switch in the push notification to the SDK
Create a campaign for sending push notifications in “Push Notifications” section
First enable push notifications in your Xcode project.
The library 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 Member Center, the Push Notifications service will appear as Configurable (not Enabled) until you create a client SSL certificate.
Drag the devtodevAppExtensions.framework into your app project.
Modify your extension.
Delete all dummy source code for your new extension
Inherit from DTDMediaAttachmentExtension in NotificationService
Use Xcode to enable push notifications in the target’s Capabilities pane:
Enable Background Modes and Remote notifications under the target’s Capabilities section:
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.
Choose an App ID from the App ID pop-up menu, and click Continue. Choose the explicit App ID that matches your bundle ID.
Follow the instructions on the next webpage to create a certificate request on your Mac, and click Continue.
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
Convert Apple certificate file to the PEM-file. Start following command-line operation from bin catalog OpenSSL.
Convert personal key from Mac OS keychain to the PEM-key:
Now you are able to create P12-file using PEM-key and iPhone developer certificate:
If you are using key from Mac OS keychain then choose PEM-version created in the previous step. Otherwise, you can use OpenSSL key for Windows OS.
Upload the .p12-file into Integration section of application settings panel (Settings -> Push Notifications):
After the certificate has been generated you can start to integrate Push SDK into your app.
1. Open the "Capabilities" tab in the XCode. Switch "Push Notifications" and "Background Modes" to ON. In "Background Modes" check "Remote notifications".
2. Add the following strings to the AppDelegate class:
If you are using iOS 12 or above, you can specify custom options for notification settings:
3. Open "Build Settings", find the parameter "Other Linker Flags", then add 2 flags: -ObjC and -lc++
4. Compile and run the app. You will need a device because the simulator does not support push notifications. Xcode will automatically choose a new provisioning profile. If an error occurred during the launch make sure that there is a correct profile set in the Code Signing Identity. You'll be asked to confirm push notifications. An app will request permission only once, if user confirms it - notifications will be accepted otherwise he won't get any push messages from your app. Users can change it in device settings.
1. Open PUSH NOTIFICATIONS section and click on the "Add new campaign" button
2. Fill in the campaign name
You can create a campaign only after at least one push token comes from devtodev SDK integrated into your application. Otherwise, the app will not be displayed in the list.
3. Choose a user group to send a message. You can choose an existing segment or create a new one
4. Enter notification details
5. Test push notification (or skip this step)
6. Confirm push gateway
7. Schedule the delivery
8. That's it!
Integration of push notification on UE4
Add the application to your space in devtodev system
Android. Get API key from Google APIs Console. It is nessesary to activate Google Cloud Messaging for Android before key generation. Detailed information on how to receive an API key you can find in native Android devtodev SDK documentation
iOS. Generate Developer or Production Certificate for the application and get Private key file (.p12) on its basis. Detailed information on how to receive a Private key file you can find in native iOS devtodev SDK documentation
Submit the data to the application settings in devtodev system
Integrate devtodev SDK to the application (see the "SDK integration" division to learn more about integrating and initializing devtodev SDK)
Set Push Notification Enabled in blueprint.
Create a campaign for sending push notifications in "Push" section
Set Push Notification Enabled in blueprint.
Fill in campaign name, select an app for delivery*
Choose user group to send a message. You can choose existing segment or create a new one
Enter notification details
Schedule the delivery
That's it!
You can create a campaign only after at least one push token comes from devtodev SDK integrated to your application. Otherwise the app will not be displayed in the list.
After a successful registration in Firebase, you can receive your keys that you will use in devtodev.
Finally, press "Sync now" in the bar that appears in the IDE:
Make sure that these functions are enabled in Package.appmanifest of you project (the flag "Toast capable" is enabled by default for Windows 10+ projects, it is absent in the manifest).
Add the following two Background Tasks in Package.appmanifest:
Keep in mind that your application must be built with the same Windows Store preferences you used in Chapter 3.2. In the "Create App Packages" window you have to log in with your Live ID and pick the appropriate application form the list. A file Package.StoreAssociation.xml will be added into the Project.
Click the Add button (+) in the upper-right corner.
Under Production, select the “Apple Push Notification service SSL (Sandbox & Production)” checkbox, and click Continue.
In the dialog that appears, select the certificate request file (with a .certSigningRequest extension), and click Choose.
Open section and click on "Add new campaign" button
Push Notifications are available only for the supported platforms: iOS, Android, Windows Store/Windows Phone 8.1/10.
To enable Push Notifications you will have to perform the following actions:
Add the application to your space in devtodev system
Android. Get API key from Google APIs Console. It is necessary to activate Google Cloud Messaging for Android before key generation. Detailed information on how to receive an API key you can find in native Android devtodev SDK documentation
iOS. Generate Developer or Production Certificate for the application and get Private key file (.p12) on its basis. Detailed information on how to receive a Private key file you can find in native iOS devtodev SDK documentation
Submit the data to the application settings in devtodev system
Integrate devtodev SDK to the application (see the "SDK integration" to learn more about integrating and initializing devtodev SDK)
Add several lines of the code to switch in the push notification to the SDK
Create a campaign for sending push-notifications in "Push" section
Go to Firebase console and then to your project or create a new one. Here is complete guide on adding your project to Firebase console and enabling Cloud messaging.
Download google-services.json from your Firebase console. Add this file into your project’s Assets folder.
Please do the following to find google-services.json:
Choose your project in the Firebase console
Choose project settings in the Project overview
3. Scroll down to the SDK setup and configuration. Click on the google-services.json
If you want to use both devtodev and Firebase Messaging services at the same time, you need to disable Firebase listener.
Find androidmanifest.xml used in your app. If you don’t use Custom Manifest, you need to create it. Tick the Custom Main Manifest checkbox:
You can read more about the manifest here.
Add the following line to the “Application” section:
You should get something like this:
Build a Windows Store App in Unity. After the app is built, Visual Studio project will be created. Proceed with the following changes.
There is a difference in the implementation of the elements mentioned below for different types of projects:
.NET + D3D: Put the following source in your App class (usually it is an App.cs file) at the end of the ApplicationView_Activated(CoreApplicationView sender, IActivatedEventArgs args) function.
.NET + XAML: Put the following source in your App class (usually it is an App.xaml.cs file) at the end of the OnLaunched(LaunchActivatedEventArgs args) and OnActivated(IActivatedEventArgs args) functions.
IL2CPP + XAML: Put the following source in your App class (usually it is App.xaml.cpp file). Add several lines of code in a generated App.xaml.cpp class. After defining headers:
And at the end of of the App::OnLaunched(LaunchActivatedEventArgs^ e) and App::OnActivated(IActivatedEventArgs^ args) functions.
For Example:
IL2CPP + D3D: Put the following source in your App class (usually it is App.cpp file). Add several lines of code in a generated App.cpp class. After defining headers:
And at the end of of the App::OnActivated(CoreApplicationView^ sender, IActivatedEventArgs^ args) function.
Make sure that these functions are enabled in Package.appmanifest of you project (the flag "Toast capable" is enabled by default for Windows 10+ projects, it is absent in the manifest).
Add the following three Background Tasks in Package.appmanifest:
Entry point for Push Notification tasks type:
Entry points for System Event tasks type:
Build an iOS App in Unity. After the app is built, Xcode project will be created. Proceed with the following changes
Enable push notifications in your Xcode project
The library 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 Member Center, the Push Notifications service will appear as Configurable (not Enabled) until you create a client SSL certificate
Add devtodevAppExtensions.framework to newly created extension. Make sure that Deployment Target is pointed as iOS 10.0 or higher:
Make sure that field Architectures contains "Standard architectures armv7, arm64" setting both in the project and the extension build settings:
Modify your extension:
Delete all dummy source code for your new extension
Inherit from DTDMediaAttachmentExtension in NotificationService
Use Xcode to enable push notifications in the target’s Capabilities pane:
Enable Background Modes and Remote notifications under the target’s Capabilities section:
Using the graphic interface:
Open the Window/devtodev menu element
Switch Push Notifications tumbler on
If you need to use push token for some aims or to handle the getting of notifications by user, add the GameObject with the following function to the scene:
Using code: Before calling Analytics.Initialize add the following strings:
1. Open PUSH NOTIFICATIONS section and click on the "Add new campaign" button
2. Fill in the campaign name, select an app for delivery 3. Choose a user group to send a message. You can choose an existing segment or create a new one 4. Enter notification details 5. Schedule the delivery 6. That's it!
You can create a campaign only after at least one push token comes from devtodev SDK integrated into your application. Otherwise, the app will not be displayed in the list.
You must also associate your application with the Windows Store app (otherwise push notifications will not be delivered). Open "Store->Associate App with the Store" menu, login with your Live ID and pick the appropriate application form the list. A file Package.StoreAssociation.xml will be added into the Project.