Android ๊ธฐ์ด ์ค์
ํธ์๋ฉ์ธ์ง ๋ฐ์ก์ ์ํ Android OS ์์ ํ์๋ก ์ค์ ํด ์ฃผ์ ์ผ ํ๋ ๊ฐ์ด๋์ ๋๋ค.
๊ฐ์ฅ ๋จผ์ ํธ์ ๋ฐ์ก์ ์ํ ํ์ ์ค์ ์ ์ํด ์๋์ ๋ ๊ฐ์ง๋ฅผ ์์๋๋ก ์งํ ํด ์ฃผ์ธ์.
FCM ์ธ์ฆ์ ์ค์
๋์๋ณด๋ ์ค์
SDK ์ค์น
ํ๋ก์ ํธ build.gradle
ํ๋ก์ ํธ build.gradleํ๋ก์ ํธ์ build.gradle ( root ํ์ผ ) ์ ์๋์ ๊ฐ์ด repository ์ฃผ์๋ฅผ ์ถ๊ฐํด์ฃผ์ธ์.
...
allprojects {
repositories {
google()
mavenCentral()
/* wisetracker sdk repository config */
maven {
def endPoint = "https://analytics.wisetracker.co.kr/console/android/sdk/github/credentials.do"
url = uri(new URL(endPoint+'?name=URI').text)
credentials {
username = new URL(endPoint+'?name=USER').text
password = new URL(endPoint+'?name=TOKEN').text
}
}
}
}
...
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
...
/* Google services */
classpath 'com.google.gms:google-services:4.3.15' // Google Services plugin
...
}
}Android 13 ์ด์์ ๋ฒ์ ์์ ํธ์ ์๋ฆผ ๊ถํ ํ๋์ ์ํ ์ค์
Android 13 ์ด์์ ๋ฒ์ ์์ ํธ์ ์๋ฆผ ๊ถํ ํ๋์ ์ํ ์ค์ ํ๋ก์ ํธ ์์ค ํน์, app ์์ค "build.gradle"์ "targetSdkVersion = 33" ์ด์์ด์ด์ผ ํฉ๋๋ค.
buildscript {
ext {
...
targetSdkVersion = 33
...app๋ชจ๋ build.gradle
app๋ชจ๋ build.gradleํ๋ก์ ํธ์ app/build.gradle ํ์ผ์ ์๋ dependencies์ ์๋์ ๊ฐ์ด Wisetracker SDK๋ฅผ ์ถ๊ฐํด์ฃผ์ธ์.
์ด ๋, Java์ Kotlin์ ๋ฐ๋ผ ์ด์ฉํ๋ ๋ชจ๋๋ช
์ด ๋ฌ๋ผ์ง๋๋ค.
...
// 1. Google Services plugin ์ถ๊ฐ
apply plugin: 'com.google.gms.google-services'
...
android {
...
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
....
// 2. Wisetracker SDK ์ ์ฉ
implementation "com.sdk.wisetracker:base_module:latest.release"
implementation "com.sdk.wisetracker:new_dot_module:latest.release"
// 3. Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:29.0.0')
// 4. Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging'
}
......
// 1. Google Services plugin ์ถ๊ฐ
apply plugin: 'com.google.gms.google-services'
...
android {
...
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
....
// 2. Wisetracker SDK ์ ์ฉ
implementation "com.sdk.wisetracker:base_module:1.0.78"
implementation "com.sdk.wisetracker:new_dot_module:1.0.47"
// 3. Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:29.0.0')
// 4. Declare the dependencies for the Firebase Cloud Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging-ktx'
}
...AuthorizationKey ๋ฑ๋ก
AuthorizationKey ๋ฑ๋ก์ Wisetracker ๊ธฐ๋ณธ SDK๊ฐ ์ด๋ฏธ ์ ์ฉ๋ ๊ฒฝ์ฐ์๋ ๋ค์ ์ ์ฉํ ํ์๊ฐ ์์ต๋๋ค. ๋ฉ์์ง ์๋น์ค๋ง ์ด์ฉํ๋ ๊ฒฝ์ฐ ๋ฑ๋ก ํด ์ฃผ์ธ์.
app/res/values/strings.xml
app/res/values/strings.xmlํ๋ก์ ํธ์ app/res/values/strings.xml ํ์ผ์ ์๋ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
์ถ๊ฐํ ์ฝ๋ ์ค 3๋ฒ ๋ผ์ธ serviceNumber์ value๋ฅผ ์ฌ๋ฐ๋ฅธ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.
<string-array name="dotAuthorizationKey">
<item name="useMode">1</item>
<item name="serviceNumber">xxxxx</item> >>> ์๋น์ค ๋ฒํธ ํ์ธ ํ ๋ณ๊ฒฝ
<item name="expireDate">14</item>
<item name="isDebug">false</item>
<item name="isInstallRetention">true</item>
<item name="isFingerPrint">true</item>
<item name="accessToken"></item>
</string-array>์ถ๊ฐํ ์ฝ๋ ์ค serviceNumber์ value๋ฅผ ์ฌ๋ฐ๋ฅธ ๊ฐ์ผ๋ก ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.
์์ด์ฆํธ๋์ปค ๋์๋ณด๋์ ๋ก๊ทธ์ธํ์ฌ ์ค์ > ์๋น์ค์ค์ ๋ฉ๋ด์์ '์๋น์ค๋ฒํธ' ํญ๋ชฉ์ ๊ธฐ์ฌ๋ ์ซ์๋ฅผ ํ์ธ ํ ๋ณต์ฌํ์ฌ serviceNumber ๊ฐ์ ๋ณ๊ฒฝ ํด ์ฃผ์ธ์.

HTTP ํต์ ํ์ฉ
์ด ๋ด์ฉ์ Wisetracker ๊ธฐ๋ณธ SDK๊ฐ ์ด๋ฏธ ์ ์ฉ๋ ๊ฒฝ์ฐ์๋ ์๋ก ์ ์ฉํ ํ์๊ฐ ์์ต๋๋ค. ๋ฉ์์ง ์๋น์ค๋ง ์ด์ฉํ๋ ๊ฒฝ์ฐ ์ฐธ์กฐํด์ฃผ์ธ์.
ํ๋ก์ ํธ์ Target API๊ฐ API Level 28 ์ด์์ผ ๊ฒฝ์ฐ์ ์ ์ฉํ๋ ์ค์ ์
๋๋ค. ์๋์ ๊ฐ์ด HTTP ํต์ ์ ํ์ฉํ๋ ๋ ๊ฐ์ง ์ค์ ์ ์ถ๊ฐํด์ฃผ์ธ์.
์์ฑ๋์ด ์๋ ์ฝ๋์, ์๋ ํ ์ค ์ง๋ฆฌ networkSecurityConfig ์ฝ๋๋ฅผ ๋ณต์ฌํ์ฌ
android:networkSecurityConfig="@xml/network_security_config"<application androidname = > ์์ ๋ถ์ฌ๋ฃ๊ธฐ ํ๋ฉด ์๋ ์ต์ข ์ฝ๋์ ๊ฐ์ ๋ชจ์์ด ๋ฉ๋๋ค.
<application androidname=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:networkSecurityConfig="@xml/network_security_config" > <!-- API Level 28 ์ด์์ผ ๊ฒฝ์ฐ ํด๋น ๋ผ์ธ ์ถ๊ฐ -->
app/res/xml/network_security_config.xml ์ค์
network_security_config.xmlํ์ผ์ ์์ฑํฉ๋๋ค.๋ก์ปฌ์์ ๊ฐ๋ฐํ๋ ๊ฒฝ์ฐ์๋ ์๋์ ๊ฐ์ด ๋ก์ปฌ ๊ฐ๋ฐํ๊ฒฝ์ ์ถ๊ฐํด์ผ metro server์ ํต์ ํ ์ ์์ต๋๋ค.
<domain includeSubdomains="true">localhost</domain>๋ก์ปฌ ํ๊ฒฝ์ ์ถ๊ฐ ํ ํ, xml ํ์ผ์ ์์ด์ฆํธ๋์ปค ๋๋ฉ์ธ์ ์ถ๊ฐ ํด ์ฃผ์ธ์.
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">trk.analytics.wisetracker.co.kr</domain>
</domain-config>
</network-security-config>trk.analytics.wisetracker.co.kr โถ๏ธ ๋๋ฉ์ธ์ ์ถ๊ฐ ํด ์ฃผ์๋ฉด ์์ด์ฆํธ๋์ปค SDK ํต์ ์ด ๊ฐ๋ฅํด์ง๋๋ค.
๊ธฐ์กด network_security_config.xml ์ค์ ์ด ๋์ด ์์ผ์ จ๋ค๋ฉด,
<domain includeSubdomains="true">trk.analytics.wisetracker.co.kr</domain>์์ด์ฆํธ๋์ปค ๋๋ฉ์ธ์ '์ถ๊ฐ' ํด์ฃผ์๋ฉด ์์ด์ฆํธ๋์ปค SDK ํต์ ์ด ๊ฐ๋ฅํฉ๋๋ค.
ํธ์์๋ฆผ ๊ถํ ์ค์ (AndroidManifest.xml)
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />"android.permission.POST_NOTIFICATIONS" ๊ถํ์ ์ถ๊ฐํฉ๋๋ค. ์ด ๊ถํ ์ค์ ์ <application> ํ๊ทธ ์์์ ์ ์ธํฉ๋๋ค.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="XXX">
<!-- Wisetracker SDK for Push -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
...
<application
android:name="ZZZ"
...>์ด๊ธฐํ
Application์ ์์๋ฐ๋ ํด๋์ค๊ฐ ์๋ Activity๋ฅผ ์์๋ฐ๋ ๊ธฐ๋ณธ ํ๋ฉด์ onCreate() ํจ์์ ์ ์ฉํด ์ฃผ์ธ์. ์ฌ๊ธฐ์ ๋งํ๋ ๊ธฐ๋ณธ ํ๋ฉด์ AndroidManifest.xml ํ์ผ์ ์ ์ธ๋ Activity ์ค, "android.intent.action.MAIN" ๊ณผ "android.intent.category.LAUNCHER" Intent-Filter ๊ฐ ์ ์ฉ๋ Activity๋ฅผ ์๋ฏธํฉ๋๋ค.
Application์ ์์๋ฐ๋ ํด๋์ค๊ฐ ์๋ Activity๋ฅผ ์์๋ฐ๋ ๊ธฐ๋ณธ ํ๋ฉด์ onCreate() ๋ฉ์๋์ ์ ์ฉํด ์ฃผ์ธ์
import com.sdk.wisetracker.new_dot.open.DOT;
public class MainActivity extends Activity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
...
// SDK ํธ์ถ
DOT.initialization(this);
...
}
...
}import com.sdk.wisetracker.new_dot.open.DOT
class MainActivity : AppCompatActivity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
...
// SDK ํธ์ถ
DOT.initialization(this)
...
}
}์๋๋ก์ด๋ ๊ธฐ์ด์ค์ ์ ์๋ฃํ์ จ์ต๋๋ค ๐
๋ค์์ผ๋ก iOS ๊ธฐ์ด์ค์ ์ ์ํ ๋จ๊ณ๋ฅผ ์งํ ํด ์ฃผ์ธ์ ๐๐ป
Last updated
Was this helpful?