Android
link 필드는 사용자를 안내하는 데 사용됩니다. 이 필드는 거래 생성 성공 응답에서 수신됩니다.
여기에서 Android 애플리케이션에서 사용자 경험을 관리하는 가장 좋은 방법을 찾을 수 있습니다:
1단계: 통합을 위한 CustomTabs 사용
app/build.gradle에 CustomTabs 사용에 필요한 의존성을 추가하세요:
implementation("androidx.browser:browser:1.5.0")
2단계: CustomTab 열기
import android.net.Uri
import androidx.activity.ComponentActivity
import androidx.browser.customtabs.CustomTabsClient
import androidx.browser.customtabs.CustomTabsIntent
class CustomTabActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
openCustomTab(<URL_CBU>)
}
fun openCustomTab(url: String) {
val builder = CustomTabsIntent.Builder()
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(this, Uri.parse(url))
}
}
3단계: AndroidManifest 수정
callback_uri를 수신하려는 Activity의 AndroidManifest.xml에 필요한 권한과 인텐트를 추가하세요. android:launchMode="singleTop" 속성과 URI 데이터를 제공하는 <data> 태그를 포함해야 합니다.
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-permission android:name="android.permission.CAMERA"/>
// 카메라 및 위치 정보에 대한 권한이 필요합니다
<activity
android:name=".CustomTabActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Customtabs"
android:launchMode="singleTop">
<intent-filter android:label="Custom Tab">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- scheme과 host는 거래 생성 시 callback_uri 필드로 제공되는 데이터입니다
callback_uri: "foobar://success?code=1234" -->
<data android:scheme="foobar" android:host="success"/>
</intent-filter>
</activity>
올바르게 작동하려면 다음 권한이 필요합니다:
- 카메라
- 위치 정보
4단계: 반환 정보 가져오기
제공된 데이터로 리다이렉트 정보를 가져오려면, Activity의 onNewIntent 메서드에서 다음 코드를 사용할 수 있습니다:
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val url = intent.data
val scheme = url.scheme // "foobar"
val host = url.host // "success"
val code = url.getQueryParameter("code") // "1234"
}
하이브리드 프레임워크에서도 Unico가 생성한 링크를 사용할 수 있습니다. 이를 위해 사용 중인 프레임워크와 네이티브 코드 간의 브리지를 만들어 문서에서 제안하는 방식을 따르거나, 이러한 통합 옵션을 제공하는 라이브러리를 사용할 수 있습니다.
애플리케이션에 WebView를 통합하는 것은 전적으로 고객의 책임입니다. 이 기능은 Unico의 라이브러리나 SDK의 일부로 제공되지 않기 때문입니다. 이러한 이유로, 저희는 애플리케이션에서 WebView를 구현하는 것과 관련된 질문이나 문제에 대해 기술 지원을 제공하지 않습니다. 설정에 대한 안내가 필요하면, 프로젝트에서 사용하는 기술(예: React Native, Flutter 등)의 공식 문서를 참고하는 것을 권장합니다.