DFINERY Growth Action Integration [Android]
FollowRequirement
Before Growth Action integration, both adbrix SDK integration and Firebase Cloud Messaging SDK (FCM) set-up are mandatory.
- adbrix SDK Integration on Android
- This guide is for Native project, React Native, Cocos2dx, Flutter. If you use Unity3D, pls follow this link to know how to Set up a Firebase Cloud Messaging Client App [Android Unity]
[[인용:안내:보통]] For Growth Action Integration
_ You can use targeting & scenario push in Growth Action.
_ You have to pay an extra charge for Growth Action. [Contact us for Growth Action Plan]
Growth Action Setting(Mandatory)
1) Firebase Server Key and Sender ID Registration
Set your Firebase Server Key and Sender ID at adbrix console.
Go to Firebase Console > Setting > Cloud Messaging, you can find your Firebase Server Key and Sender ID.
a. Find your Firebase Server Key and Sender ID in the Firebase console.
b. Go to adbrix console > Growth Action > Setting. Set Server Key and Sender ID like the below screenshot.
2) Get google-services.json config file:
From Firebase Project > Add App. Then download google-services.json and put it into your Android project
3) Download FCM library
In your root-level (project-level) Gradle file (build.gradle
), add rules to include the Google Services Gradle plugin. Add Google Services plugin Example: classpath 'com.google.gms:google-services:4.3.8'
Check that you have Google's Maven repository, as well.
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.8' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
In your module (app-level) Gradle file (usually app/build.gradle
), apply the Google Services Gradle plugin:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
Add Firebase SDK to your project
implementation 'com.google.firebase:firebase-messaging:22.0.0'
4) Edit your app manifest
Extend FirebaseMessagingService class and add your custom service to Manifest file
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
In this class add AdBrixRm.onMessageReceived() on onMessageReceived method.
public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); AdBrixRm.onMessageReceived(getApplicationContext(), remoteMessage); } }
class MyFirebaseMessagingService :FirebaseMessagingService() { override fun onMessageReceived(message: RemoteMessage) { super.onMessageReceived(message) AdBrixRm.onMessageReceived(applicationContext, message) } }
Add meta-data for default push notification channel
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="app_default_channel" />
Add the following to your app's manifest for local push notification feature
<receiver android:name="com.igaworks.v2.core.push.notification.AbxPushReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <action android:name="com.igaworks.v2.core.pushServiceImplement.CLIENT_PUSH_RECEIVE"/> </intent-filter> </receiver>
5) Token Registration
You can access push notification token by extending FirebaseMessagingService and overriding onNewToken.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onNewToken(String token) {
Log.d(TAG, "Refreshed token: " + token);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
// Send token data to AdBrix
AdBrixRm.setRegistrationId(token);
}
}
class MyFirebaseMessagingService : FirebaseMessagingService(){
override fun onNewToken(token: String?) {
Log.d(TAG, "Refreshed token: $token")
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
// Send token data to Adbrix
AdBrixRm.setRegistrationId(token)
}
}
Push on / off
Either of the APIs is mandatory for Growth Action. You can control push using those APIs.
// Push On
AdBrixRm.setPushEnable(true);
// Push Off
AdBrixRm.setPushEnable(false);
// Push On
AdBrixRm.setPushEnable(true)
// Push Off
AdBrixRm.setPushEnable(false)
[[인용:경고:보통]]Default Setting
Default is 'Push off'.
Before using growth action, getting agreement from users is mandatory.
You have to also call 'Push On' API from users who have already agreed with the push.
[[인용:안내:보통]] Congratulation
You are ready to use Growth Action.
If you want to set an optional setting such as color and image, continue following this guide.
Growth Action Setting (Optional)
Icon and Color
The following is an example of the push notification icon and color setting.
// Using Color class ARGB
AdBrixRm.setPushIconStyle(this,"smallicon","largeicon",Color.argb(1,255,0,0));
// Using AdBrixRm class
AdBrixRm.setPushIconStyle(this,"smallicon","largeicon",AdBrixRm.PushColor.Yellow);
// Using Color class ARGB
AdBrixRm.setPushIconStyle(this,"smallicon","largeicon",Color.argb(1,255,0,0))
// Using AdBrixRm class
AdBrixRm.setPushIconStyle(this,"smallicon","largeicon",AdBrixRm.PushColor.Yellow)
[[인용:위험:보통]] Caution!!
1) Type file name without the filename extension.
2) You have to add all the image files to use into the drawable folder.
3) If a large icon is set on server push, it is prior to other pushes.
4) ARGB changes app name color.
5) You can use Color class ARGB to set push color.
6) You can use AdBrixRm class to set push color.
V2 Push Channel Set-up
You should use Notification Channel to make a notification over Android 8.0. You should apply "AdBrixRm.setPushEnable(true)" before you make a notification channel through the following API.
You can set the name, description, importance, and vibration of notification. (Only 1 channel is made by this API)
//context, channelName, description, importance, vibration
AdBrixRm.setNotificationChannel(this,"myPushChannelName", "my Channel description",NotificationManager.IMPORTANCE_HIGH, true)
Use the value on the below list of importance. Vibration set-up is available only with the default and high set-up.
- NotificationManager.IMPORTANCE_HIGH : Notification ON / Sound / Pop-up
- NotificationManager.IMPORTANCE_DEFAULT : Notification ON / Sound
- NotificationManager.IMPORTANCE_LOW : Expanded Notification ON / Mute
- NotificationManager.IMPORTANCE_MIN : Collapsed Notification / Mute
- NotificationManager.IMPORTANCE_NONE : Notification OFF
[[인용:위험:보통]]Notice
With this API, you can change channelName and channelDescription whenever you want. However, the importance and vibration of the channel are unchangeable.
Notification Setting
You can set a heads-up notification and the option of push on a lock screen.
The following is an example code of a notification setting.
AdBrixRm.setNotificationOption(this,NotificationCompat.PRIORITY_MIN,NotificationCompat.VISIBILITY_SECRET);
AdBrixRm.setNotificationOption(this,NotificationCompat.PRIORITY_MIN,NotificationCompat.VISIBILITY_SECRET)
Heads-up Notification(PRIORITY)
- PRIORITY_MAX: use a heads-up notification
- PRIORITY_HIGH: use a heads-up notification
- PRIORITY_DEFAULT: no heads-up notification
- PRIORITY_LOW: no heads-up notification
- PRIORITY_MIN: no heads-up notification
Push on Lock Screen (VISIBILITY)
- VISIBILITY_SECRET: no alarm on a lock screen
- VISIBILITY_PRIVATE: no message, but the alarm on a lock screen
- VISIBILITY_PUBLIC: entire message on a lock screen
Push Listener Registration
This is how to set up a local / server push listener. We recommend registering push listener in the Application class.
public class MyApplication extends Application implements AdBrixRm.onTouchRemotePushListener,AdBrixRm.onTouchLocalPushListener{
@Override
public void onCreate() {
super.onCreate();
// SDK init API must call first
AbxActivityHelper.initializeSdk(MyApplicationClass.this, "your_adbrix_remastered_app_key", "your_adbrix_remastered_secret_key");
// Server Push
AdBrixRm.setRemotePushMessageListener(this);
// Local Push
AdBrixRm.setLocalPushMessageListener(this);
}
// Local Push Listener
@Override
public void onTouchLocalPush(String onTouchLocalPushString) {
Log.d("my_tag", "onReceiveLocakPushmessage" + onTouchLocalPushString);
}
// Server Push Listener
@Override
public void onTouchRemotePush(String onTouchRemotePushString) {
Log.d("my_tag", "onReceiveRemotePushMessage" + onTouchRemotePushString);
}
}
class MyApplication: Application(), AdBrixRm.onTouchRemotePushListener,AdBrixRm.onTouchLocalPushListener{
override fun onCreate() {
super.onCreate()
// SDK init API must call first
AbxActivityHelper.initializeSdk(MyApplicationClass.this, "your_adbrix_remastered_app_key", "your_adbrix_remastered_secret_key");
// Server Push
AdBrixRm.setRemotePushMessageListener(this)
// Local Push
AdBrixRm.setLocalPushMessageListener(this)
}
// Local Push Listener
override fun onTouchLocalPush(onTouchLocalPushString: String?) {
Log.d("my_tag", "onReceiveLocakPushmessage" + onTouchLocalPushString)
}
// Server Push Listener
override fun onTouchRemotePush(onTouchRemotePushString: String?) {
Log.d("my_tag", "onReceiveRemotePushMessage" + onTouchRemotePushString)
}
}
Each listener receives the following data depending on its type.
- local push: all the data set on a notification
- server push: the deep link value
[[인용:위험:보통]] Caution!!
When you register a remote push listener, you have to deal with NullPointerException. We do not send any data when you choose the 'AppOpen' option in adbrix console.
[[인용:위험:보통]]Caution!!
All of app Push Listeners must call after SDK initialize.
[[인용:위험:작게]] If 'An operation is not implemented: Not yet implemented' error is reported
Regardless of the SDK, sometimes the error occurs when you use TODO comments within a callback method.
If there is TODO comments in the callback method, please remove it.
Local Push Setting
Text Push
This is an example code of a text push message.
AdBrixRm.BigTextPushProperties bigTextPushMessageProperties = new AdBrixRm.BigTextPushProperties()
.setTitle("PushTest")
.setContentText("This is ContentText")
.setBigContentTitle("BigContentTitle")
.setSummaryText("Summary Text")
.setBigText("This is big Text.This is big Text.This is big Text.This is big Text.This is big Text.")
.setSecond(5)
.setEventId(12345)
.setDeepLinkUri("adbrixrm://main");
AdBrixRm.setBigTextClientPushEvent(this,bigTextPushMessageProperties, true);
val bigTextPushMessageProperties = AdBrixRm.BigTextPushProperties()
.setTitle("PushTest")
.setContentText("This is ContentText")
.setBigContentTitle("BigContentTitle")
.setSummaryText("Summary Text")
.setBigText("This is big Text.This is big Text.This is big Text.This is big Text.This is big Text.")
.setSecond(5)
.setEventId(12345)
.setDeepLinkUri("adbrixrm://main")
AdBrixRm.setBigTextClientPushEvent(this,bigTextPushMessageProperties, true)
The following screenshot is an example of how it looks on devices.
property value
- setSecond: push timer(second)
- setEventId: event ID to control local push
- setDeeplinkUri: deep link Uri when push is clicked
- bool alwaysShown: whether to show push or not while an app is running
Image Push
This is an example code of push with text and image.
AdBrixRm.BigPicturePushProperties bigPicturePushProperties = new AdBrixRm.BigPicturePushProperties()
.setTitle("ImagePushTest")
.setContentText("This is ContentText")
.setBigContentTitle("BigContentTitle")
.setSummaryText("Summary Text")
.setBigPictureUrl("http://myimage/image.png")
.setResourceId(R.drawable.adbrix_image)
.setSecond(10)
.setEventId(67890)
.setDeepLinkUri("adbrixrm://main");
AdBrixRm.setBigPictureClientPushEvent(this,bigPicturePushProperties,true);
val bigPicturePushProperties = AdBrixRm.BigPicturePushProperties()
.setTitle("ImagePushTest")
.setContentText("This is ContentText")
.setBigContentTitle("BigContentTitle")
.setSummaryText("Summary Text")
.setBigPictureUrl("http://myimage/image.png")
.setResourceId(R.drawable.adbrix_image)
.setSecond(10)
.setEventId(67890)
.setDeepLinkUri("adbrixrm://main")
AdBrixRm.setBigPictureClientPushEvent(this,bigPicturePushProperties,true)
property value
- setBigPictureUrl
_ image URL for the push
_ setResourceId is prior to setBigPictureUrl - setResourceId
_ image resource ID for push
_ setResourceId is prior to setBigPictureUrl - setSecond: push timer(second)
- setEventId: set local push ID
- setDeeplinkUri: set deeplink on local push
- bool alwaysShown: whether show push or not while an app is running
[[인용:경고:보통]] Recommend using 2:1 aspect ratio and less than 1350x675 image.
Local Push Management
This is how to manage pushes that are set on your app.
- getPushEventList: You can see a list of current local pushes in JSONArray.
- cancelClientPushEvent: You can cancel a specific push with its ID.