Wepin Android Widget Library를 초기화하는 방법은 다음과 같습니다.
import com.wepin.android.widgetlib.WepinWidget
WepinWidget
인스턴스를 생성하기전에 아래와 같이 앱의 Activity Context , 앱 등록 후 할당받은 App ID와 App Key를 WepinWidgetParams 객체에 전달해 주세요.
val wepinWidgetParams = WepinWidgetParams(
context = this,
appId = "your-wepin-app-id",
appKey = "your-wepin-app-key"
)
앞서 생성한 WepinWidgetParams
를 전달하면서 WepinWidget
인스턴스를 생성해 주세요.
val wepinWidget = WepinWidget(wepinWidgetParams)
WepinWidget
인스턴스생성 후 initialize
메서드를 호출하여 초기화를 합니다.
val res = wepinWidget.initialize(attributes)
parameters
atrributes
<WepinWidgetAttribute>
defualtLanguage
<String>
위젯 화면의 기본 언어 설정, 기본 값은 'en'
입니다. 현재 지원하는 언어는 'ko'
, 'en'
,'ja'
입니다.
defaultCurrency
<String>
위젯 화면의 기본 통화 설정, 기본 값은 'USD'
입니다. 현재 지원하는 통화는 'KRW'
, 'USD'
, 'JPY'
입니다.
Return value
CompletableFuture
<Boolean>
정상적으로 잘 된 경우 true , 실패한 경우 false 를 반환합니다.
Example
public class MainActivity extends ComponentActivity {
private WepinWidget wepinWidget;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_example_main);
initView();
// Wepin Login Library 초기화
// ...
// Wepin PIN Pad Library 초기화
WepinWidgetParams wepinWidgetParams = new WepinWidgetParams(
this,
"your-wepin-app-id",
"your-wepin-app-key"
);
wepinWidget = new WepinWidget(wepinWidgetParams null);
WepinWidgetAttributes attributes = new WepinWidgetAttributes("en", "USD");
CompletableFuture<Boolean> res = wepinWidget.initialize(attributes);
if (res != null) {
res.whenComplete((result, error) -> {
if (error == null) {
System.out.println(result);
} else {
System.out.println(error);
}
});
}
// ...
}
}
class MainActivity : ComponentActivity() {
private lateinit var wepinWidget: WepinWidget
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_example_main)
initView()
// Wepin Widget Pad Libary 초기화
val wepinWidgetParams = WepinWidgetParams(
context = this,
appId = 'your-wepin-app-id',
appKey = 'your-wepin-app-key'
)
wepinWidget = WepinWidget(wepinWidgetParams)
var attributes = WepinWidgetAttribute("en", "USD")
val res = wepinWidget.initialize(attributes)
res?.whenComplete { infResponse, error ->
if (error == null) {
println(infResponse)
} else {
println(error)
}
}
// ...
}
isInitialized
isInitialized
메서드를 이용해서 WepinWidget
인스턴스가 정상적으로 초기화 되었는지 확인할 수 있습니다.
반환값은 아래와 같습니다.
<Boolean>
초기화가 정상적으로 잘 된 경우 true , 실패한 경우 false 를 반환합니다.
Example
if(wepinWidget.isInitialized()){
// Success to initialize WepinPin
}
if(wepinWidget.isInitialized()){
// Success to initialize WepinPin
}
changeLanguage
wepinWidget.changeLanguage("ko")
위젯화면에 표시되는 언어를 변경합니다. 현재 'ko'
, 'en'
, 'ja'
만 지원됩니다.
Parameters
language
<String>
위젯 화면에 표시될 언어
currency
<String> optional
위젯 화면에 표시될
화Return value
CompletableFuture
<Boolean>
정상적으로 잘 된 경우 true , 실패한 경우 false 를 반환합니다.
Example
wepinWidget.changeLanguage("ko", null).whenComplete((res, err) -> {
if (err == null) {
System.out.println(res);
} else {
System.out.println(err);
}
});
wepinWidget.changeLanguage("ko").whenComplete{ res, err ->
if (err == null) {
println(res)
} else {
println(err)
}
}