간단 가이드

이 안내서는 SDK를 설치하고 초기화 하는 방법을 보여줍니다.

SDK는 AndroidStudio를 통한 탑재 방법을 지원하며 단말기가 푸시 알림을 수신받고 서버에 사용자의 정보를 동기화 할 수 있도록 지원합니다.

Step 1. SDK 설치하기

Step 2. Volley 라이브러리 추가하기

dependencies {
    ...
    implementation 'com.android.volley:volley:1.1.1' //최신버전 적용 권장
}

Step 3. FirebaseMessaging 적용하기

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.1.0' //구글 서비스 플러그인
    }
}

allprojects {
    // ...
    repositories {
        google() // Google의 Maven 리포지터리
        // ...
    }
}
dependencies {
    ...
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
}

// 맨 밑에 Google 서비스 적용 코드를 삽입하여야 합니다.
apply plugin: 'com.google.gms.google-services'

Step 4. AndroidManifest.xml 수정하기

Private 서비스를 사용할 경우 추가 권한이 필요합니다. 상세 가이드의 Private 서비스 활성화시키기를 참고하여 주시기 바랍니다.

<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<receiver
    android:name="com.apms.sdk.push.PushReceiver"
    exported="false">
    <intent-filter>
        <action android:name="com.google.android.fcm.intent.RECEIVE"/>
        <action android:name="org.mosquitto.android.mqtt.MSGRECVD"/>
    </intent-filter>
</receiver>
<service
    android:name="com.apms.sdk.push.FCMPushService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

Step 5. 소스코드상에 SDK 적용하기

protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    //SDK 설정
    APMS sdk = new APMS.Builder()
                .setFirebaseSenderId("997255892867")
                .setServerAppKey("402f4c2a26364e991573")
                .setServerUrl("https://api.pushpia.com:444/")
                .setNotificationConfig(
                        new NotificationConfig.Builder()
                                .setSmallIcon(R.drawable.ic_notifications_black_24dp)
                                .create()
                )
                .build(getApplicationContext());
    
    //DeviceCert API 호출
    new DeviceCert(getApplicationContext()).request(null, new APIManager.APICallback() {
        @Override
        public void response(String code, JSONObject json)
        {
            ...
        }
    });
    
    //SetConfig API 호출
    ...
}

Step 6. 마무리 하기

⬆ 맨 위로