Step 1. Select the Push Notification Channel
- Go to the Settings → Channels section of your personal edna Pulse account.
- Select an existing push notification channel or connect a new one according to the instructions.
- Make sure you have:
- An Android app with minSdk no earlier than 21 (Android 5) and targetSdk no later than 33 (Android 13).
- Google Service Account JSON file. See the instructions on how to get the file.
- The google-services.json file from Firebase.
- A device with Android 5.0 or higher or an Android emulator with the Google Play Services.
- A current version of Android Studio.
Step 2. Enter App Data from Firebase
- Register the application in Firebase according to the instructions.
- Get the Google Service Account JSON file according to the instructions.
- Go to the Settings → Channels → Setting Android Application section of your personal edna Pulse account.
- Enter the application name.
- Upload the received Google Service Account JSON file.
- Click Save and Continue.
Step 3. Add Dependencies to build.gradle File
- Add dependencies to the project’s build.gradle file — specify the edna repository address and add Google services to the list of dependencies.
buildscript { //... dependencies { //... classpath "com.google.gms:google-services:4.3.10" } //... allprojects { repositories { //... maven { url 'https://maven-pub.edna.ru/repository/maven-releases'} } }
- To the build.gradle file of the app, apply the plugin, and add the edna library to the list of dependencies.
apply plugin: 'com.google.gms.google-services' dependencies { //... implementation platform("com.edna.android:push-x-bom:2.0.0") }
- Specify the app unique access key for the edna push services in app manifest:
<meta-data android:name="com.pushserver.android.appId" android:value="unique edna access key from Step 2 App Settings" />
- Add the google-services.json file to the root of the app directory of your app in Android Studio.
- The edna library is initialized automatically. However, if Configuration.Provider is implemented in the app, you should use manual initialization.
Step 4. Add Code for Processing Notification Taps
If a client taps a notification or its action button, the app launches. The edna library processes the tap-through data and passes Intent
to the app’s start Activity
. You need to process the data received from the edna library in the app’s onCreate
and onNewIntent
methods. The edna library passes an action string you specified in the broadcast to Intent
.
Following is an example of the code for processing a client’s notification tap-through:
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) //... intent?.extras?.getParcelable<PushAction>(PUSH_ACTION_KEY)?.let { // Client navigation based on the passed string with PUSH_ACTION_KEY = "action" redirectUser(it.action) } //... } override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) //... intent?.extras?.getParcelable<PushAction>(PUSH_ACTION_KEY)?.let { // Client navigation based on the passed string with PUSH_ACTION_KEY = "action" redirectUser(it.action) } //... } }
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PushAction extraAction = getIntent().getExtras().getParcelable(PUSH_ACTION_KEY); // Client navigation based on the passed string with PUSH_ACTION_KEY = "action" redirectUser(extraAction); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); PushAction extraAction = getIntent().getExtras().getParcelable(PUSH_ACTION_KEY); // Client navigation based on the passed string with PUSH_ACTION_KEY = "action" redirectUser(extraAction); } }
Step 5. Support Registration of Client Devices in edna
- Select the type of how the device is registered on the platform.
A client’s device appears in edna after it is registered. Two methods – automatic or manual – are possible. For now, only the automatic registration is available, but the manual type will be added soon as well.- With automatic registration, the edna library registers the device in edna by itself. This method is simpler, it does not require you to manage the registration process, but it is not recommended for sending confidential data.
- Once the manual type is available, your backend will be able to register the client’s device in edna using a specific API method.
- To register a client in edna, call the
login
library method specifying ID andSubscriberIdType
of the client. Call the method only after the client is successfully authorized in your app.
PushX.login("79001002030", SubscriberIdType.PHONE_NUMBER)
PushX.login("79001002030", SubscriberIdType.PHONE_NUMBER.INSTANCE)
The following types of SubscriberIdType
are available:
- Phone number (
PhoneNumber
) - Email address (
Email
) - IDs in Facebook, Telegram, Google, Apple, Yandex (
FacebookId
,TelegramId
,GoogleId
,AppleId
,YandexId
) - Internal user IDs (
ExtUserId
,CookieId
) - UTM tag (
UTM
)
- When the user is deauthorizing, call the
logout
library method to log out the device from edna:
PushX.logout()
Step 6. Compile and Launch App
- Connect the device to the Internet to check the integration.
- Compile and launch the app.
- After the app is launched, on the Settings > Channels > Setting Android Application page in the edna Pulse, click Save and continue. A page with step 6 will open, you need to wait until the registration process is completed.
Step 7. Check Device Connection and Test Receiving Push Notifications
In this step, edna helps you verify the integration has been completed correctly. If it has, you will see the name of your test device and the button to send a test push notification. Note that if you launched the app on several devices, you will only see the last connected one.
- Click Test push notifications.
- Verify the push notification is delivered and displayed on your test device.
- If yes, confirm receiving the push by clicking Yes.
All done! You can now create a cascade and set up a broadcast using this push channel.