CASH BUTTON SDK - FLUTTER
- 1 안내사항
- 2 참조 모듈 설정
- 2.1 참조 모듈 정보
- 3 메소드 호출
- 3.1 메소드 정보
- 3.2 main.dart
- 3.3 Application
- 3.4 MainActivity
- 3.5 onBackPressed - (optional)
- 4 추가기능
안내사항
CASH BUTTON 기본 연동 가이드 확인 후 본 문서를 통해 연동 부탁 드립니다.
참조 모듈 설정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// build.gradle
android {
...
...
}
flutter {
...
...
}
// implementation files('libs/캐시버튼_SDK_파일명.aar')
implementation files('libs/avatye_cashbutton_v1.2.0.aar')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'com.google.android.gms:play-services-basement:17.4.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'joda-time:joda-time:2.10.5'
implementation 'com.google.zxing:core:3.4.0'
implementation('com.github.bumptech.glide:glide:4.11.0')
kapt 'com.github.bumptech.glide:compiler:4.11.0'
/** Buzzvill sdk */
implementation("com.buzzvil:buzzad-benefit:2.9.1") {
exclude group: 'com.buzzvil', module: 'buzzad-benefit-pop'
exclude group: 'com.buzzvil', module: 'buzzad-benefit-notification'
}
/** mobon sdk */
implementation('com.mobon.sdk:com.mobon.sdk:1.0.4.18') {
transitive = true
exclude group: 'com.google.android.gms'
}
/** service-channeltalk */
implementation ('com.zoyi.channel:plugin-android:7.2.0'){
exclude group: "androidx.gridlayout", module: 'gridlayout'
}
/** igaworks ssp sdk & mediation */
implementation 'com.igaworks.ssp:IgawAdPopcornSSP:2.4.2'
/** ad-mediation-group (unityads,vungle,facebook) */
implementation 'com.unity3d.ads:unity-ads:3.4.8'
implementation 'com.vungle:publisher-sdk-android:6.7.1'
implementation 'com.facebook.android:audience-network-sdk:6.2.0'
implementation "com.kakao.adfit:ads-base:3.4.0"
/** androidx.appcompat:appcompat:x.x.x 을 사용하고 있지 않을 경우 추가 필요 */
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
참조 모듈 정보
| Kotlin 언어 모듈 |
| |
| google play service |
| |
| Joda-Time providers a quality replacement for the java date and time classes. |
| |
| |
| 캐시 버튼 실시간 문의 대응 모듈 |
| AD NETWORK |
| |
| |
|
위 패키지를 사용하지 않을 경우만 추가 합니다. |
메소드 호출
MethodChannel 을 통해 Channel 생성 후 PlatformAPI(Android Platrom API)와 통신한다.
캐시버튼 동작을 위해서는 Application, MainActivity(메인 액티비티 / Launcher, Main) 설정이 필요합니다.
메소드 정보
캐시버튼 SDK 초기화
|
|
Application Class를 사용하고 있지 않았다면, 캐시버튼 SDK 연동을 위해 AndroidManifest.xml에 해당 Application Class를 생성하고 등록해야 합니다. |
|
|
CashButtonConfig.initialize() 함수에 들어가는 데이터 클래스 |
| |
Platform과 통신하기 위한 Channel 생성
|
|
|
|
캐시버튼 SDK 시작
|
|
|
onCreate() → setContentView(…) 후에 위치해야 하며, 해당 함수 마지막에 위치 바랍니다. |
캐시버튼 Dock 상태
|
|
|
|
|
| ||
캐시버튼 Visibility
|
|
| CashButton → Visible.Gone |
| CashButton → Visible.View |
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class _SamplePageState extends State<SamplePage> {
static const platform = const MethodChannel('메소드 채널명');
...
// 비동기로 데이터를 받고 수행 Future
Future<void> _getCashButton(bool check) async {
String value;
try {
value = await platform.invokeMethod('methodA');
} on PlatformException catch (e) {
value = '네이티브 코드 실행 에러 ${e.message}';
}
}
// 캐시버튼 문의
Future<void> _actionSuggestion() async{
String actionValue;
try{
actionValue = await platform.invokeMethod('methodB');
} on PlatformException catch (e) {
actionValue = '캐시버튼 문의 실행 에러 ${e.message}';
}
}
Application
Application Class 초기화 되지 않을 경우 앱 실행에 문제가 발생합니다.
Android 5.0(API 수준 21) 미만의 경우 Multidex 적용이 필요합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// App
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
...
/** cash-button initializer */
CashNotifyModel notifyModel = new CashNotifyModel(this, true, "앱명", 0, 0);
CashButtonConfig.initializer(this, CashButtonPosition.END, notifyModel);
}
}
// AndroidManifest.xml
<manifest ... >
<application
android:name=".App"
...
...
</manifest>
MainActivity
메인으로 사용되는 액티비티에 설정 합니다.
onCreate() → setContentView(…) 후에 위치해야 합니다.
setContentView(…) 를 통한 Layout 설정 완료 후 설정되어야 합니다.
callback::onSuccess() → callback 이벤트를 통한 앱 로직을 추가 하지 마세요.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// MainActivity.java
// imports
import com.avatye.sdk.cashbutton.ICashButtonBackPressedListener;
import com.avatye.sdk.cashbutton.ICashButtonCallback;
import com.avatye.sdk.cashbutton.ui.CashButtonLayout;
import org.jetbrains.annotations.NotNull;
...
private static final String CHANNEL = "메소드 채널명";
private CashButtonLayout cashButton;
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
// flutter 와 통신할 때
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
(call, result) -> {
if (call.method.equals("methodA")) {
...
/** cashButton init */
CashButtonLayout.init(this, new ICashButtonCallback() {
@Override
public void onSuccess(@NotNull CashButtonLayout cashButtonLayout) {
cashButton = cashButtonLayout;
}
});
} else if (call.method.equals("methodB")) {
...
CashButtonConfig.actionSuggestion(this);
} else {
result.notImplemented();
}
}
);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
// option
@Override
public void onBackPressed() {
if (cashButton != null) {
cashButton.onBackPressed(b -> {
if (b) {
finish();
}
});
}
super.onBackPressed();
}
...
onBackPressed - (optional)
해당 설정을 했을 경우 Listener:onBackPressed 값
false : 팝업 광고가 노출되어 있는 상태 또는 캐시버튼 독이 노출되어 있는 경우
(독이 노출되어 있는경우 감춰진 상태로 전환)
true : 팝업 광고가 노출되지 않고, 캐시버튼 독이 감춰진 상태
추가기능
문의하기
캐시버튼과 관련된 문의를 받기 위한 메뉴 노출 가이드 입니다.
친구초대
친구초대 메세지의 타이틀을 변경합니다.