Integrate Growth Action [Flutter]
FollowGetting started
DFINERY Growth Action provides functions to help customers engage with their engagement marketing activities.
[Learn about Growth Action services]
Using the functions provided by DFINERY, you can create audience groups and conduct personalized marketing targeting each audience.
[[Quote: Guide: Normal]] To use Growth Action, you must use the DFINERY paid plan.[ Contact Us ]
Required
In order to integrate
the DFINERY
growth action function, integration
with the DFINERY (Adbrix)
SDK is required.
You must complete the basic adbrix integration steps to be able to integrate with Growth Action.
Set up Android push service
In order to use Growth Action in Flutter, settings for receiving push messages are required within the Android/iOS project within the Flutter project.
Firebase Integration
In order to integrate the push function,
the DFINERY (Adbrix)
basic SDK and Firebase Cloud Messaging SDK (hereinafter referred to as FCM) are required.
You must complete the basic adbrix integration steps to be able to integrate with Growth Action.
[[Quote:Danger:Moderate]]
Caution
The sending method using Firebase Server Key and Sender ID will be discontinued after June 13, 2024 due to the discontinuation of support for Firebase's existing HTTP API. Please link according to the Firebase certificate issuance and registration guide introduced below.
View previous linking methods
Register Firebase Server Key and Sender ID
To use the Definery Growth Action, you must register the Firebase Server Key / Sender ID in
the Definery Console
.
You can check your Firebase Server Key / Server ID in Firebase Console -> Settings -> Cloud Messaging.
a. Check the Firebase Server Key and Sender ID in the Firebase console.
b. Enter the key value you checked in the Growth Action - Settings menu of the adbrix console.
Issue a Firebase certificate
1. Log in to the service account .
2. Select the project for which you want to issue a key.
If there is no project, it means that the Firebase project has not been created. Refer to Add Firebase to your Android project to create a Firebase project.
3. Click ⋮ in the Actions section at the bottom right.
4. Click Key Management from the dropdown.
5. Select Add Key.
If there is a key that has already been generated, it means that there is a history of generating a key in the past and you can use that key. If you cannot find the key, please generate a new key.
6. Click Create New Key from the dropdown.
7. After selecting JSON, click Create.
8. Key issuance has been completed.
Register in the Firebase Certificates Console
[[Quote:Warning:Normal]] Console Settings Open Date
The ability to register Firebase certificates in the console will be available on June 13th.
1.Connect to the console .
2. In the left panel, click Settings under GrowthAction.
3. In the Android Push Setting tab, click Register in Firebase Cloud Messaging Certificate.
4. Click the Upload button to upload your key.
5. After uploading is complete, click the Confirm button.
6. Click Save to apply the certificate.
7. The certificate has been registered in the console.
Push reception settings
Register the receiver below in AndroidManifest.xml.
Set up push reception using AdbrixrmFlutterPlugin.onMessageReceived within onMessageReceived of the FirebaseMessagingService you created.
public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); AdbrixrmFlutterPlugin.onMessageReceived(getApplicationContext(), remoteMessage); } }
Token value setting
To set the Firebase Token value in adbrix, add the Token value using AdbrixrmFlutterPlugin.setRegistrationId in onNewToken() of FirebaseMessagingService.
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
AdbrixrmFlutterPlugin .setRegistrationId(token);
}
}
And add the following code to the Application class you use so that the Token value can be updated as follows.
public class MyApplicationClass extends FlutterApplication { @Override public void onCreate() { super.onCreate(); refreshToken(); } private void refreshToken(){ FirebaseMessaging.getInstance().getToken() .addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (!task.isSuccessful()) { return; } String token = task.getResult(); AdbrixrmFlutterPlugin.setRegistrationId(token); } }); } }
Push icon and color settings
Sets the color of the icon and app name displayed when receiving a push.
AdbrixrmFlutterPlugin.setPushIconStyle("smallicon","largeicon",0x1000FF00);
The push icon set this way is displayed as shown below.
[[Quote:Danger:Moderate]]
Caution
1) Enter only the image file name without the extension.
2) You need to add all images with that name to the Drawable folder in your android project within your Flutter project for all resolutions.
3) If largeIcon is set in server push, the icon will be displayed with priority.
Push channel settings
To create a notification on Android 8.0 or higher, you must use NotificationChannel. To use this API, AdbrixrmFlutterPlugin.setPushEnable(true); must be applied first.
Set the name and description of the notification channel . (Only 1 channel is created)
Android(JAVA)
AdbrixrmFlutterPlugin.setNotificationChannel( "myPushChannelName" , "my Channel description" );
Flutter(Dart)
AdBrixRm.setNotificationChannel("channelName", "channelDescription");
Set up push notifications
Set the visibility of push notifications. The push notification settings API below is only available on Android 8.0 and below.
AdbrixrmFlutterPlugin.setNotificationOption(Context context, int priority, int visibility)
Heads-up notification settings (PRIORITY)
- 2 : PRIORITY_MAX : Use heads-up notifications
- 1: PRIORITY_HIGH: Use heads-up notifications
- 0 : PRIORITY_DEFAULT : Do not use heads-up notifications
- -1 :PRIORITY_LOW : Do not use heads-up notifications
- -2 : PRIORITY_MIN : Do not use heads-up notifications
Lock screen notification settings (VISIBILITY)
- -1 : VISIBILITY_SECRET : Disable lock screen notifications
- 0 : VISIBILITY_PRIVATE : Lock screen notifications are displayed, but the content is not displayed.
- 1 : VISIBILITY_PUBLIC : Show entire contents on lock screen
iOS push service settings
APNS certificate registration
Register a certificate to use the iOS Gross Action service.
Register in Definary Console / Growth Action / Settings / iOS Push Setting. [
How do I register a certificate?
]
[[Quote:Warning:Normal]]
Please check.
- You must register a p12 certificate without a password.
- p12 certificate must be registered as Production type.
- iOS Gross Action Server Push only works in Production environments.
- iOS Gross Action Server Push only works in Production environments.
Add Capability
Complete the following to integrate with iOS Gross Action Service.
- Add Background Modes and Push Notifications to the app's Signing & Capabilities -> Capability
- In Background Modes, check Remote notifications
Add framework
To use the iOS Gross Action service, please complete the following:
- In the General section, add NotificationCenter.framework and UserNotifications.framework.
Add Notification Service Extension
Add Notification Service Extension for using GrossActions on iOS.
a. Click the '+' button at the bottom of Xcode
b. Select Notification Service Extension and click the Next button.
c. Enter Product Name and complete
d. Add AdBrixRmKit.xcframework to the General settings of the Extension.
The framework is currently located in the Pods -> AdBrixRmKit folder of your project.
e. Once the Extension settings are complete, open the NotificationService file that was automatically added to the folder and modify it as follows.
//NotificationService.swift import UserNotifications import AdBrixRmKit class NotificationService : AdBrixPushService {}
//NotificationService.h #import #import @interface NotificationService : AdBrixPushServiceObjC @end //NotificationService.m #import "NotificationService.h" @implementation NotificationService
@end
Edit AppDelegate
To use the iOS gross action service, add and modify the following contents to AppDelegate.
a. Get Device Token value
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){ AdbrixrmFlutterPlugin.setRegistrationId(deviceToken: deviceToken) }
/- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [AdbrixrmFlutterPlugin setRegistrationIdWithDeviceToken:deviceToken]; }
b. Add push On / Off function according to user notification permission consent in didFinishLaunchingWithOptions
class AppDelegate: FlutterAppDelegate, UNUserNotificationCenterDelegate { ... application.registerForRemoteNotifications() let unCenter = UNUserNotificationCenter.current() unCenter.delegate = self let options : UNAuthorizationOptions = [.alert,.sound,.badge] unCenter.requestAuthorization(options: options, completionHandler: {(granted,error) in if granted{ DispatchQueue.main.async { // If Push permission is granted enable AdBrix Push AdbrixrmFlutterPlugin.setPushEnable(toPushEnable: true) application.registerForRemoteNotifications() } } else{ // If Push permission is not granted disable AdBrix Push AdbrixrmFlutterPlugin.setPushEnable(toPushEnable: false) } }) ... }
//AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [application registerForRemoteNotifications]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ if(granted){ [[UIApplication sharedApplication] registerForRemoteNotifications]; [AdbrixrmFlutterPlugin setPushEnableToPushEnable:true]; } else{ [AdbrixrmFlutterPlugin setPushEnableToPushEnable:false]; } }]; ... }
[[Quote:Warning:Normal]]
Check default settings
The default setting for Definery is 'Push off'.
Therefore, after completing the gross action integration, you must get consent from users to receive push notifications and then call the Push On API.
Users who have previously agreed to receive push notifications must also call the Push On API to receive push notifications.
c. Add push click tracking function
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { //remote push tracking AdbrixrmFlutterPlugin.remotePushOpen(center: center, response: response)
completionHandler() }
- (void) userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotificationResponse:(UNNotificationResponse )response withCompletionHandler:(void (^)(void))completionHandler{
//remote push tracking [AdbrixrmFlutterPlugin remotePushOpenWithCenter:center response:response];
completionHandler(); }
d. Add code to set whether to display push messages while the app is running
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { AdbrixrmFlutterPlugin.willPresentRemotePush(notification: notification, completionHandler: completionHandler) }
- (void) userNotificationCenter:(UNUserNotificationCenter )center willPresentNotification:(UNNotification*)notification withCompletionHandler:(void(^)(UNNotificationPresentationOptions))completionHandler {
[AdbrixrmFlutterPlugin willPresentRemotePush:notification completionHandler:completionHandler]; }
Using Push
Push On/Off
This is a mandatory API that must be linked to use the adbrix gross action service. You can manage the push service with this API.
AdbrixrmFlutterPlugin.setPushEnable(true) // Push On AdbrixrmFlutterPlugin.setPushEnable(false) // Push Off
[[Quote:Warning:Normal]]
Check default settings
The default setting for
Definery
is 'Push off'.
Therefore, after completing the gross action integration, you must get consent from users to receive push notifications and then call the Push On API.
Users who have previously agreed to receive push notifications must also call the Push On API to receive push notifications.
push notification listener
Set up a listener for the push service. Through this, you can handle push clicks containing deep links and receive deep link information from the push. The push listener adds the listener to Flutter after adding settings in the Android / iOS project.
Android
Add a listener in the Application class.
public class MyApplicationClass extends FlutterApplication { @Override public void onCreate() { super.onCreate();
...
... AdbrixrmFlutterPlugin.setRemotePushMessageListener();
...
... }
}
iOS
Add a listener in the Appdelegate class.
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
...
...
AdbrixrmFlutterPlugin.setRemotePushMessageListener() ...
... }
//AppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ ...
...
[AdbrixrmFlutterPlugin setRemotePushMessageListener]; ...
... }
Flutter
Once Andoid/iOS setup is complete, add a push listener in the Flutter project as shown below.
import 'package:adbrixrm_flutter/adbrixrm.dart';
...
...
AdBrixRm.setPushRemoteCallbackListener((event) {
debugPrint("PUSH_REMOTE = $event");
});
Notification subscription and opt-out settings
In order to integrate the DFINERY Growth Action feature, you need to set up a subscription for notifications.The SDK allows subscription and rejection settings for channels other than push, and also provides a function to retrieve the currently set value.
[[인용:보통:위험]] This function operates based on user audience.Therefore, before setting, be sure to call AdBrixRm.login() API to set user_id.
Subscribe to and opt out of notifications
Set the users notification consent value with the DFINERY server.
Flutter
Future setSubscriptionStauts(
{required bool info,
required bool marketing,
required bool marketingPush,
required bool marketingSms,
required bool marketingKakao,
required bool marketingNight,
required bool marketingNightPush,
required bool marketingNightSms,
required bool marketingNightKakao}) async
//Example of use void setSubscriptionStatus() async {
try {
await AdBrixRm.setSubscriptionStauts(
info: true,
marketing: true,
marketingPush: true,
marketingSms: true,
marketingKakao: false,
marketingNight: false,
marketingNightPush: false,
marketingNightSms: false,
marketingNightKakao: false);
_alert("success");
} catch (e) {
_alert(e.toString());
}
}
-
Parameter information
- info: Informational notification
- marketing: Advertising notification
- marketingPush: Advertising notification push channel
- marketingSms: Advertising notification SMS channel
- marketingKakao: Advertising notification notification channel
- marketingNight: Nighttime advertising notification
- marketingNightPush: Night advertising notification push channel
- marketingNightSms: Nighttime advertising notification SMS channel
- marketingNightKakao: Nighttime advertising notification notification channel
[[인용:보통:위험]] Whether or not you agree to receive informational notifications is treated as a higher concept than whether or not you agree to receive advertising notifications.Therefore, if the informational flag is UNSUBSCRIBED, the push will not be sent even if the advertising flag is SUBSCRIBED.
Get notification subscription information
Flutter
Future getSubscriptionStatus() async
//Return Map
["informative": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_push": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_sms": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_kakao": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_night": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_night_push": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_night_sms": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED",
"marketing_night_kakao": "SUBSCRIBED" || "UNSUBSCRIBED" || "UNDEFINED"]
// Example of usage void getSubscriptionStatus() async {
try {
var getResult = await AdBrixRm.getSubscriptionStatus();
var toShow = """
informative ${getResult!["informative"]}
marketing ${getResult["marketing"]}
m_push ${getResult["marketing_push"]}
m_sms ${getResult["marketing_sms"]}
m_kakao ${getResult["marketing_kakao"]}
m_night ${getResult["marketing_night"]}
m_night_push ${getResult["marketing_night_push"]}
m_night_sms ${getResult["marketing_night_sms"]}
m_night_kakao ${getResult["marketing_night_kakao"]}
""";
_alert(toShow);
} catch (e) {
_alert(e.toString());
}
}
KakaoTalk settings
These are settings for using Kakao Notification Talk and Friend Talk. *KAKAOID: 10-digit Kakao ID received through Kakao Sync API
Flutter
Future setKakaoId({required String kakaoId}) async
//Example of use void _setKakao() async {
try {
await AdBrixRm.setKakaoId(kakaoId: "123412341234");
_alert("success");
} catch (e) {
var s = e as PlatformException;
_alert(s.code);
}
}
SMS settings
Settings for using SMS. *PHONE_NUMBER: Country code that complies with E.164 + number minus “+” (Example: 8210********)
Flutter
Future setPhoneNumber({required String phoneNumber}) async
//Example of use void _setPhoneNumber() async {
try {
await AdBrixRm.setPhoneNumber(phoneNumber: "821012345678");
_alert("success");
} catch (e) {
var s = e as PlatformException;
_alert(s.code);
}
}
Pop-up Message
DFINERY pop-up messages do not require separate integration.
You can expose a pop-up message by triggering an event delivered through the DFINERY SDK, and all settings can be made in the DFINERY console.
Pop-up message deep link
If an in-app message click event listener is registered in Native, the deep link listener code will be called when using the deep link set in the pop-up message.
import 'adbrixrm_flutter/adbrixrm.dart'
.
.
.
//The following linkage locations are examples. Please link them as needed.
@override
void initState () {
super .initState();
AdBrixRm .setDeeplinkListener((deeplinkString) {
debugPrint( "DEEPLINK = $deeplinkString" );
});
}
[[Quote:Guide:Normal]] Please be careful with the settings as the deep link code of the native OS is also called.
click event listener
The users pop-up message click event is delivered through the configured listener.
You can use this listener to define additional actions for click events.
Android
Add a listener in the Application class.
public class MyApplicationClass extends FlutterApplication { @Override public void onCreate() { super.onCreate(); AdbrixrmFlutterPlugin.setInAppMessageClickListener();
} }
iOS
Add the following to didFinishLaunchingWithOptions in the AppDelegate class.
@objc class AppDelegate: FlutterAppDelegate{
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
...
... AdbrixrmFlutterPlugin.setInAppMessageClickListener()
...
... } }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
...
[AdbrixrmFlutterPlugin setInAppMessageClickListener];
...
... }
Flutter
Once Andoid/iOS setup is complete, add an in-app message listener in the Flutter project as shown below.
AdBrixRm.setOnReceiveInAppMessageClickListener((event) {
debugPrint("IAM_CLICK = $event");
});
Click listener passed value details
The types and examples of values passed through the click listener are as follows.
- actionId (String): button_1, button_2, image, sticky
- actionType (String): close, deeplink_and_close, weblink, weblink_and_close, dont_show_me_today_and_close
- actionArg (String): weblink address, deeplink path
- isClosed (Boolean): Whether the pop-up message has been closed.