개발자 가이드
User GuideDeveloper GuideAPI Guide🏠
English
English
  • 홈
  • 공통
    • Unified ID Linkage Scenario
    • Constant
    • FAQ
  • 플랫폼 별 가이드
    • Android
      • Link up
      • Event
      • Set User Identification Information
      • User Profile Settings
      • Action
        • Push
        • In-app messages
        • Notification Talk
        • Message
      • Privacy Policy
        • Support for Privacy Protection
        • Preparing for data disclosure requirements on Google Play
      • Release Notes
    • iOS
      • Link up
      • Event
      • Set user identification information
      • User Profile Settings
      • Action
        • Push
        • In-app messages
        • Notification Talk
        • message
      • Release Notes
    • HybridApp
      • Link up
    • Web
      • Link up
      • Event
      • Set user identification information
      • User Profile Settings
      • Action
        • In-app messages
        • Notification Talk
        • Message
      • Advanced use cases
        • Additional Settings
      • Release Notes
Powered by GitBook
On this page
  • Before you start
  • Register whether to allow receiving push notifications
  • Registering Firebase information in the console
  • Adding Support Library Dependency
  • Firebase Cloud Messaging Integration
  • Add Firebase to your Android project
  • Setting up Firebase Cloud Messaging
  • Linking tokens to DFINERY
  • Link when getting the current registration token
  • Integration when monitoring token generation
  • Connecting push notification channels to DFINERY
  • Create a push notification channel
  • Register the created push notification channel ID
  • Setting up push notification icons
  • Processing push notifications
  • Handling push notification clicks
  • Complete
  • Learn more
  • Follow the steps to create a notification channel
  • How to issue a Firebase user authentication private key file
  • How to check caller ID
  1. 플랫폼 별 가이드
  2. Android
  3. Action

Push

PreviousActionNextIn-app messages

Last updated 2 months ago

DFINERY uses Firebase Cloud Messaging to receive push notifications, so your application needs to integrate with Firebase.

Before you start

Register whether to allow receiving push notifications

In the case of push notifications for advertising purposes, prior consent must be obtained from the user in accordance with . In order to register with DFINERY that the user has permitted push notifications, please perform the following series of tasks.

  1. Notify users to allow push notifications

  2. Register the value of the user's permission/rejection intention in the user profile.

and enter values ​​for the items to which the user has consented. The code below is an example of allowing consent to receive informational and advertising messages for push channels.

Map<String, Object> consents = new HashMap<>();
consents.put(DFUserProfile.PUSH_OPTIN, true);
consents.put(DFUserProfile.PUSH_ADS_OPTIN, true);
DfineryProperties.setUserProfiles(consents);
val consents = mapOf<String, Any>(
    DFUserProfile.PUSH_OPTIN to true, 
    DFUserProfile.PUSH_ADS_OPTIN to true
)
DfineryProperties.setUserProfiles(consents)

Registering Firebase information in the console

, go to Additional Settings/Channel Additional Settings/Push/Android Settings Management, enter the sender ID, and upload the Firebase user authentication information private key file in JSON format.

Adding Support Library Dependency

  1. Open a build.gradle file inside your app's module directory.

  2. Add Support Library dependency to dependencies.

 dependencies {
    implementation 'androidx.core:core:1.9.0'
}
 dependencies {
    implementation ("androidx.core:core:1.9.0")
}

Firebase Cloud Messaging Integration

Add Firebase to your Android project

Setting up Firebase Cloud Messaging

Linking tokens to DFINERY

To link a token issued by Firebase to DFINERY, please write as follows.

Link when getting the current registration token

FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() {
    @Override
    public void onComplete(@NonNull Task<String> task) {
        if (!task.isSuccessful()) {
            Log.w(TAG, "Fetching FCM registration token failed", task.getException());
            return;
        }

        // Get new FCM registration token
        String token = task.getResult();
        DfineryProperties.setPushToken(token);
    }
});
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task ->
    if (!task.isSuccessful) {
        Log.w(TAG, "Fetching FCM registration token failed", task.exception)
        return@OnCompleteListener
    }

    // Get new FCM registration token
    val token = task.result
    DfineryProperties.setPushToken(token)
})

Integration when monitoring token generation

@Override
public void onNewToken(@NonNull String token) {
    Log.d(TAG, "Refreshed token: " + token);
    DfineryProperties.setPushToken(token);
}
override fun onNewToken(token: String) {
    Log.d(TAG, "Refreshed token: $token")
    DfineryProperties.setPushToken(token)
}

Connecting push notification channels to DFINERY

Create a push notification channel

Register the created push notification channel ID

Register the ID of a notification channel created using the setDefaultNotificationChannelId() method of DfineryConfig or using res/values/dfinery.xml using.

DfineryConfig config = new DfineryConfig.Builder()
    .setDefaultNotificationChannelId("NOTIFICATION_CHANNEL_ID")
    .build();
Dfinery.getInstance().init(this, "SERVICE_KEY", config);
val config = DfineryConfig.Builder()
    .setDefaultNotificationChannelId("NOTIFICATION_CHANNEL_ID")
    .build()
Dfinery.getInstance().init(this, "SERVICE_KEY", config)
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="com_igaworks_dfinery_default_notification_channel_id" translatable="false">
      NOTIFICATION_CHANNEL_ID
    </string>
</resources>

Setting up push notification icons

To display push notifications, you need to set an icon. Please setNotificationIcon() use the method of DfineryConfig or res/values/dfinery.xml use to set the icon.

Since the notification itself is an icon that is displayed in the top status bar as well as the color of the image is ignored, we recommend an image with a transparent color (alpha channel) of 72x72px.

DfineryConfig config = new DfineryConfig.Builder()
    .setNotificationIcon(R.drawable.icon)
    .build();
Dfinery.getInstance().init(this, "SERVICE_KEY", config);
val config = DfineryConfig.Builder()
    .setNotificationIcon(R.drawable.icon)
    .build()
Dfinery.getInstance().init(this, "SERVICE_KEY", config)
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <drawable name="com_igaworks_dfinery_notification_icon">
      @drawable/NOTIFICATION_ICON_DRAWABLE 
    </drawable>
</resources>

Processing push notifications

@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    if(Dfinery.getInstance().handleRemoteMessage(getApplicationContext(), remoteMessage.getData())){
        //dfinery push
    }else{
        //This is not a push notification sent from Dfinery.
    }
}
override fun onMessageReceived(remoteMessage: RemoteMessage) {
  if(Dfinery.getInstance().handleRemoteMessage(applicationContext, remoteMessage.getData())){
        //dfinery push
    }else{
        //This is not a push notification sent from Dfinery.
    }
}

Handling push notification clicks

Complete

Push settings are complete.

Learn more

Follow the steps to create a notification channel

1. Create a notification channel.

  • The first parameter id represents the ID of the notification channel.

  • The second parameter, name, is the name of the notification channel. This value Settings/Notifications is exposed to the user in.

NotificationChannel notificationChannel = new NotificationChannel("NOTIFICATION_CHANNEL_ID", "NOTIFICATION_CHANNEL_NAME", NotificationManager.IMPORTANCE_HIGH);
val notificationChannel = NotificationChannel("NOTIFICATION_CHANNEL_ID", "NOTIFICATION_CHANNEL_NAME", NotificationManager.IMPORTANCE_HIGH)

2. Set a description for the notification channel. (Optional)

The value Settings/Notifications is exposed to the user in.

notificationChannel.setDescription("NOTIFICATION_CHANNEL_DESCRIPTION");
notificationChannel.description = "NOTIFICATION_CHANNEL_DESCRIPTION"

3. Set whether the notification channel vibrates or not. (Optional)

The value of the notification channel always takes precedence over all settings set in the DFINERY console except 'Expose push messages while the app is running'.

notificationChannel.enableVibration(true);
notificationChannel.enableVibration(true)

4. Set the notification sound for the notification channel. (Optional)

Here's an example of setting the system default notification sound to play.

Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
        .setUsage(AudioAttributes.USAGE_NOTIFICATION)
        .build();
notificationChannel.setSound(soundUri, audioAttributes);
val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val audioAttributes = AudioAttributes.Builder()
    .setUsage(AudioAttributes.USAGE_NOTIFICATION)
    .build()
notificationChannel.setSound(soundUri, audioAttributes)

5. Register the created notification channel in NotificationManager.

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(notificationChannel)

6. Done.

How to issue a Firebase user authentication private key file

2. Select the project for which you want to issue a key.

3. Click ⋮ in the Actions section at the bottom right.

4. Click Key Management from the drop-down.

5. Select Add Key.

If there is a key already created, it means that there is a history of creating a key in the past and you can use that key. If you cannot find the key, please create a new key.

6. Click Create New Key from the dropdown.

7. Select JSON and click Create.

8. Key issuance is complete.

How to check caller ID

  1. Select a project.

  2. In the left panel, click the ⚙️ icon to the right of the project overview.

  3. Click Project Settings.

  4. In the Project Settings top tab, click Cloud Messaging.

DFINERY requires to create push notifications, so complete the following series of steps:

by following the instructions in Add Firebase to your Android project provided by Firebase.

provided by Firebase, and apply the following:

Since tokens do not change frequently, we recommend writing them in the method of an object that inherits Application so that the code is not called frequently.

Override method in a class that inherits FirebaseMessagingService to register the token in DFINERY.

Starting with Android 8.0, you need to create a notification channel to receive notifications. Please refer to the instructions in provided by Android and .

When a push is received, a push notification is received by an object that inherits FirebaseMessagingService. DFINERY creates a notification based on the received push payload, so please write the following in the method of the object.

When you click on a push with deep link information, set in the deep link will be executed. If the deep link has no information, android.intent.action.MAIN the Activity with the action will be executed.

For information on how to associate a deep link with an Activity, see

Here is an example of creating a notification channel. There is also , so please refer to it.

The notification channel API is supported on and higher.

The third parameter importance indicates of push notifications that will be received through this notification channel.

1. Log in to

If there is no project, it means that the Firebase project has not been created. Refer to to create a Firebase project.

Go to

Check

the Support Library
Add Firebase to your Android project
Follow the instructions in Setting up a Firebase Cloud Messaging client app on Android
Add a service that inherits FirebaseMessagingService to your app manifest
Write a runtime notification permission request that applies to Android 13 and above
Device Registration Token Access Linking
onCreate()
the onNewToken(String)
Creating and Managing Notification Channels
Creating a Notification Channel
onMessageReceived(RemoteMessage)
the Activity
Creating App Content Deep Links on Android.
an example provided by Android
Android 8.0
the importance
the service account.
Add Firebase to your Android project
the Firebase Console.
the caller ID
.
the Information and Communications Network Act
Please refer to Setting consent to receive notifications
In the DFINERY console
How to check caller ID
How to issue a Firebase user authentication private key file