이 안내서는 SDK를 설치하고 초기화 하는 방법을 보여줍니다.
SDK는 AndroidStudio를 통한 탑재 방법을 지원하며 단말기가 푸시 알림을 수신받고 서버에 사용자의 정보를 동기화 할 수 있도록 지원합니다.
.aar 파일의 형태로 제공됩니다.어플리케이션이 Android X 용으로 빌드 될 경우 APMSX SDK를 사용해야 하며 그렇지 않을 경우 APMS SDK를 사용해야 합니다.
이 두 가지 SDK 중 반드시 하나를 선택하여 추가해야 합니다.
org.eclipse.paho.client.mqttv3-1.2.0(mlog) 파일의 경우 Private 서비스를 사용하는 사용자에게 필요하며 사용하지 않을 경우 추가하지 않아도 무방합니다. 관련된 내용은 통합가이드의 Private 서비스 활성화시키기를 참고하여 주시기 바랍니다.
SDK_Android_APMS_xxx.aar : SDK를 사용하기 위한 라이브러리 파일SDK_Android_APMSX_xxx.aar : SDK를 사용하기 위한 Android X 대응 전용 라이브러리 파일org.eclipse.paho.client.mqttv3-1.2.0(mlog).jar : Private 서비스 활성화시 필요한 라이브러리 파일상단 메뉴에서 File/New/New Module을 클릭합니다.

팝업 창에서 import .JAR/.AAR Package를 선택한 후 Next를 클릭합니다.

추가할 .aar 파일을 선택한 후 Finish를 클릭합니다.

Android 프로젝트의 Build Sync가 완료되면 상단 메뉴에서 File/Project Structure...을 클릭합니다.

어플리케이션에서 +를 클릭하여 .aar 파일을 선택하고 OK를 클릭합니다.


.aar 파일의 추가가 완료되었습니다.

dependencies {
...
implementation 'com.android.volley:volley:1.1.1' //최신버전 적용 권장
}google-services.json 파일이 필요합니다.
google-services.json 파일을 다운로드 받아 주시기 바랍니다.

Firebase 프로젝트로 이미 이관된 경우를 참고해주시기 바랍니다.Project Overview 우측 아이콘을 클릭하여 프로젝트 설정에 진입합니다.


google-services.json 파일을 복사하여 붙여넣어주시기 바랍니다.

루트 수준 build.gradle 파일에 규칙을 추가하여 google-services 플러그인 및 Google의 Maven 저장소를 포함합니다.
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.1.0' //구글 서비스 플러그인
}
}
allprojects {
// ...
repositories {
google() // Google의 Maven 리포지터리
// ...
}
}com.android.support:support-v4 라이브러리는 반드시 26.1.0 버전 이상이여야 합니다.com.android.support:appcompat-v7 라이브러리는 반드시 26.1.0 버전 이상이여야 합니다. 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'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"/>Android 9.0의 프레임워크 보안 변경사항에 대응하기 위하여 다음의 일련의 작업을 진행하여 주시기 바랍니다.
src/main/res에 xml 디렉토리를 추가하여 주시기 바랍니다.

network_config XML 파일을 생성하여 주시기 바랍니다.

network_config를 요구사항에 맞게 하나를 선택하여 작성합니다.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">api.pushpia.com</domain>
</domain-config>
</network-security-config><?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>AndroidManifest의 application에 작성한 network_config를 적용합니다.
<application
...
android:networkSecurityConfig="@xml/network_config">
</application>Builder를 사용하여 초기화 해주시기 바랍니다. 아래 예시는 필수 항목들만을 표시하였습니다. 보다 자세한 내용은 상세 가이드를 참고하여 주시기 바랍니다.
setFirebaseSenderId() : FCM 발신자 IDsetServerAppKey() : MSG-API 서버의 어플리케이션 키setServerUrl() : MSG-API 서버의 URLsetNotificationConfig#setSmallIcon() : 푸시 알림의 Small Icon설정 하고 난 뒤 사용자의 정보를 서버에 등록하기 위해 DeviceCert와 SetConfig API를 반드시 호출하여 주시기 바랍니다.
예시
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 호출
...
}상세 가이드API 사용가이드