Integrating Growth Action [Flutter]
FollowGetting Started
DFINERY Growth Action provides functions to help customers engage with their engagement marketing activities.
[Learn about the Growth Action service]
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
DFINERY
integrating with the Growth Action feature requires the
DFINERY (Adbrix)
SDK integration.
You must complete the adbrix basic integration steps to enable Growth Action integration.
Android Push Service Settings
To use Growth Action in Flutter, you need to set up to receive push messages within the Android/iOS projects in your 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.
[[Caution: Risk: Moderate]]NoticeThe sending method using Firebase Server Key and Sender ID will no longer be supported after June 13, 2024, due to the discontinuation of support for the existing Firebase HTTP API. Please integrate according to the Firebase certificate issuance and registration guide introduced below.
View previous integration method
Register Firebase Server Key, Sender ID
To use the DFINERY Growth Action, you must register the Firebase Server Key / Sender ID in the
DFINERY Console
.
You can check the Firebase Server Key / Server ID in the Firebase console -> Settings -> Cloud Messaging.
a. Check the Firebase Server Key and Sender ID in the Firebase console.
b. Enter the verified key value in the Growth Action - Settings menu of the adbrix console.
Issuing a Firebase Certificate
1. Access 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, so refer to Adding Firebase to your Android project to create a Firebase project.
3. Click on ⋮ in the task at the bottom right.
4. Click on Key Management from the dropdown.
5. Select Add Key.
If a key has already been generated, it means there is a history of a previously generated key, and you can use that key. If the key cannot be found, please generate a new key.
6. Click Create New Key from the dropdown.
7. Select JSON and click create.
8. The key issuance has been completed.
Register Firebase certificate in console
[[Citation:Warning:Normal]] Console setup opening date
The feature to register Firebase certificates in the console is scheduled to open on June 13th.
1.Access the console .
2. Click on Settings of GrowthAction in the left panel.
3. In the Android Push Setting tab, click Register in the Firebase Cloud Messaging certificate.
4. Click the upload button to upload the key.
5. After completing the upload, click the confirm button.
6. Click Save to apply the certificate.
7. The certificate has been registered in the console.
Push notification settings
Register the following receiver in AndroidManifest.xml.
<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>
In the onMessageReceived of the FirebaseMessagingService you wrote, set up push reception using AdbrixrmFlutterPlugin.onMessageReceived.
public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); AdbrixrmFlutterPlugin.onMessageReceived(getApplicationContext(), remoteMessage); } }
Set Token Value
To set the Token value of Firebase in adbrix, add the Token value using AdbrixrmFlutterPlugin.setRegistrationId within 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 are using 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<String>() { @Override public void onComplete(@NonNull Task<String> 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 in this way is exposed as shown below.
[[Quote: Danger: Moderate]]
Precautions
1) Enter only the name of the image file without the extension.
2) You must add all images with the corresponding name to the Drawable folder within the android project in the Flutter project for all resolutions.
3) If you have set a largeIcon in the server push, that icon will be displayed with priority.
Push Channel Settings
To create notifications on Android 8.0 and above, 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 one channel is created)
Android(JAVA)
AdbrixrmFlutterPlugin.setNotificationChannel("myPushChannelName", "my Channel description");
Flutter(Dart)
AdBrixRm.setNotificationChannel("channelName", "channelDescription");
Push Notification Settings
Sets the exposure level of push notifications. The push notification settings API below is only available on Android versions below 8.0.
AdbrixrmFlutterPlugin.setNotificationOption(Context context, int priority, int visibility)
Head-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 : Do not use lock screen notifications
- 0 : VISIBILITY_PRIVATE : Lock screen notifications are displayed, but the content is not shown
- 1 : VISIBILITY_PUBLIC : Display all content on the lock screen
iOS Push Service Settings
APNS Certificate Registration
Register the certificate to use the iOS Growth Action Service.
Register in the DFINERY Console / Growth Action / Settings / iOS Push Setting. [
How do I register the certificate?
]
[[Quote:Warning:Normal]]
Please make sure to check.
- You must register a p12 certificate without a password.
- The p12 certificate must be registered as a Production type.
- iOS Gross Action Server Push works only in the Production environment.- iOS Growth Action Server Push works only in the Production environment.
Add Capability
Complete the following tasks to integrate the iOS Growth Action service.
- Add Background Modes and Push Notifications to the app's Signing & Capabilities -> Capability
- Check Remote notifications in Background Modes
Add framework
Complete the following items to use the iOS Growth Action service.
- Add NotificationCenter.framework and UserNotifications.framework in the General section.
Add Notification Service Extension
Add a Notification Service Extension to use Growth Action in iOS.
a. Click the '+' button at the bottom of Xcode
b. Select Notification Service Extension and click the Next button
c. Enter the Product Name and complete
d. Add AdBrixRmKit.xcframework to the General settings of the relevant Extension.
The framework is located in the Pods -> AdBrixRmKit folder of the current project.
e. Once the extension setup is complete, open the automatically added NotificationService file in the folder and modify it as follows.
//NotificationService.swift import UserNotifications import AdBrixRmKit class NotificationService : AdBrixPushService {}
//NotificationService.h #import <UserNotifications/UserNotifications.h> #import <AdBrixRmKit/AdBrixPushServiceObjC.h> @interface NotificationService : AdBrixPushServiceObjC @end //NotificationService.m #import "NotificationService.h" @implementation NotificationService
@end
Modify AppDelegate
To use the iOS Growth Action service, add and modify the AppDelegate with the following content.
a. Retrieve 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 feature according to user notification permission agreement 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 the dictionary is 'Push off'.
Therefore, after completing the growth action integration, you must call the Push On API after obtaining push reception consent from users.
Existing users who have already consented 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 트래킹 AdbrixrmFlutterPlugin.remotePushOpen(center: center, response: response)
completionHandler() }
- (void) userNotificationCenter:(UNUserNotificationCenter )center didReceiveNotificationResponse:(UNNotificationResponse )response withCompletionHandler:(void (^)(void))completionHandler{
//remote push 트래킹 [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 integrated to use the adbrix Gross Action service. This API allows you to manage push services.
AdbrixrmFlutterPlugin.setPushEnable(true) // Push On AdbrixrmFlutterPlugin.setPushEnable(false) // Push Off
[[Quote:Warning:Normal]]
Check Default Settings
The default setting for the dictionary
is 'Push off'.
Therefore, after completing the growth action integration, you need to call the Push On API after obtaining push reception consent from users.
Existing users who have already agreed to receive push notifications must also call the Push On API to receive push notifications.
Push Notification Listener
Setting up a listener for push services. Through this, you can handle push clicks with deep links and receive the deep link information of the push.After adding the settings in the Android/iOS project, add the listener to Flutter.
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 within 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 the Android / iOS settings are completed, add the push listener within the Flutter project as follows.
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 opt-out settings not only for push notifications but also for other channels, and it also provides the functionality to retrieve the current settings.
[[인용:보통:위험]] This function operates based on user audience.Therefore, please make sure to call the AdBrixRm.login() API to set the user_id before configuration.
Subscribe and Unsubscribe Notifications
Set the users notification consent value with the DFINERY server.
Flutter
Future<void> 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
//사용 예시 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 Talk Channel
- marketingNight : Nighttime Advertising Notification
- marketingNightPush : Nighttime Advertising Notification Push Channel
- marketingNightSms : Nighttime Advertising Notification SMS Channel
- marketingNightKakao : Nighttime Advertising Notification Notification Talk 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 promotional 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
This is the setting for using Kakao Notification Talk and Friend Talk. *KAKAOID: 10-digit Kakao ID received through the Kakao Sync API
Flutter
Future setKakaoId({required String kakaoId}) async
//사용 예시 void _setKakao() async {
try {
await AdBrixRm.setKakaoId(kakaoId: "123412341234");
_alert("success");
} catch (e) {
var s = e as PlatformException;
_alert(s.code);
}
}
SMS Settings
This is the configuration for SMS usage. *PHONE_NUMBER : The value excluding "+" from the country code + number compliant with E.164 (Example : 8210********)
Flutter
Future setPhoneNumber({required String phoneNumber}) async
//사용 예시 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.
Popup message deep link
If a native in-app message click event listener is registered, the deep link listener code will be called when using the deep link set in the popup message.
import 'adbrixrm_flutter/adbrixrm.dart'
.
.
.
//다음 연동 위치는 예시입니다. 필요한 곳에 알맞게 연동해주세요.
@override
void initState() {
super.initState();
AdBrixRm.setDeeplinkListener((deeplinkString) {
debugPrint("DEEPLINK = $deeplinkString");
});
}
Please note that the deep link code of the native OS is also called, so be careful with the settings.
Click Event Listener
The users pop-up message click event is delivered through the configured listener.
You can define additional actions for the click event using this listener.
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 the Android / iOS settings are complete, add an in-app message listener within the Flutter project as shown below.
AdBrixRm.setOnReceiveInAppMessageClickListener((event) {
debugPrint("IAM_CLICK = $event");
});
Click Listener Pass Value Details
The type and example of the value 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 popup message is closed.