APMS SDK 1.0 User Guide

문서 이력관리

일자 변경 내용 작성자
2015.08.25 초기 버전 작성 양동민
2016.01.20 에티켓 모드 추가함 양동민

첨부파일

파일명 설명 용량
google-play-services.jar GCM 관련 라이브러리 3,416,020 byte
apms-sdk-base.jar APMS 라이브러리 198,461 byte
org.eclipse.paho.client.mqttv3.1.jar Private Server 접속 라이브러리 131,045 byte
volley_201408200633.jar APMS API 호출 시 사용하는 통신 라이브러리 88,767 byte
apms.propreties APMS 설정 파일 586 byte
version.xml Google Play Service를 사용하기위한 version 설정 파일 130 byte

1. 라이브러리 적용 방법

1.1 전달해드린 *. jar 파일을 적용하는 Project 폴더중 libs 폴더로 이동.

enter image description here

1.2 아래 그림과 같이 프로젝트를 새로고침후 적용 확인

enter image description here

1.3 'apms.properties' 파일을 assets 폴더에 저장.

# APMS APP KEY & API SERVER URL
gcm_project_id=$(Google_Project_Number)
app_key=$(App_key)
api_server_url=$(Msg_Api_Url)

# MQTT SETTING
mqtt_flag=$(mqtt_flag)
mqtt_server_url_ssl=$(mqtt_ssl_url)
mqtt_server_url_tcp=$(mqtt_tcp_url)
mqtt_server_keepalive=$(mqtt_keepalive)

# DEBUG MODE
debug_tag=APMS
debug_flag=Y
debug_log_falg=Y

# APMS SETTING
screen_wakeup_flag=Y
push_popup_showing_time=9999999
push_popup_showing_flag=N
noti_receiver=$(noti_receiver)
push_popup_activity=$(push_popup_activity)

2. AndroidManifest.xml 설정

2.1 Permission 추가

<!-- push --> 
<permission android:name="$(project_package).permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="$(project_package).permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.VIBRATE" />
<!-- push -->

<!-- network -->
<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" />
<!-- network -->

<!-- storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- storage -->

<!-- state -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- state -->

2.2 GCM receiver 추가

<!-- apms GCM Receiver -->
<receiver
    android:name="com.apms.sdk.push.PushReceiver"
    android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="$(project_package)" />
    </intent-filter>
</receiver>

2.3 PushPopupActivity 추가

<!-- apms push popup activity -->
<activity
    android:name="${push_popup_activity}"
    android:theme="@style/push_popup_theme"
    android:excludeFromRecents="true"
    android:exported="false"
    android:screenOrientation="portrait"
    android:configChanges="orientation" />

2.4 PushNotiReceiver 추가

<!-- apms push clickNotiReceiver -->
<receiver android:name="${noti_receiver_class}" >
    <intent-filter>
        <action android:name="${noti_receiver}" />
    </intent-filter>
</receiver>

2.5 Private Server service 및 receiver 추가

<!-- APMS Private RestartReceiver -->
<receiver android:name="com.apms.sdk.push.mqtt.RestartReceiver">
    <intent-filter>
        <action android:name="ACTION_MQTT_PING" />
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.USER_PRESENT" />
        <action android:name="android.intent.action.ACTION_PACKAGE_RESTARTED" />
    </intent-filter>
</receiver>
    
<!-- APMS Private connectionChangeReceiver -->
<receiver android:name="com.apms.sdk.push.mqtt.ConnectionChangeReceiver" android:label="NetworkConnection">
    <intent-filter>
        <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
    </intent-filter>
</receiver>
    
<!-- Private PUSH Service -->
<service
    android:name="com.apms.sdk.push.mqtt.MQTTService"
    android:enabled="true"
    android:exported="true"
    android:label="PushService"
    android:process="${process_name}" />
    
<!-- Private PUSH Receiver -->
<receiver android:name="com.apms.sdk.push.PushReceiver" >
    <intent-filter>
        <action android:name="org.mosquitto.android.mqtt.MSGRECVD" />
        <category android:name="${project_package}" />
    </intent-filter>
</receiver>

2.6 Data Sender service 및 receiver 추가

<!-- APMS Data Sender Service -->
<service
    android:name="com.apms.sdk.service.DataSenderService"
    android:enabled="true"
    android:exported="true"
    android:label="SenderService"
    android:process="${process_name}" />
        
<!-- APMS Data Sender receiver -->
<receiver android:name="com.apms.sdk.service.SenderSeviceReceiver" >
    <intent-filter>
        <action android:name="SENDER.START" />
        <action android:name="SENDER.STOP" />
    </intent-filter>
</receiver>

2.7 Notification 설정 값 추가

<meta-data android:name="APMS_NOTI_CONTENT" android:value="${noti_content}" />

2.8 Notification Icon 설정 값 추가

<meta-data android:name="APMS_SET_ICON" android:resource="@drawable/${icon_file_name}" />
<meta-data android:name="APMS_SET_LARGE_ICON" android:resource="@drawable/${icon_file_name}" />

2.9 Push Alram Sound 설정 값 추가

<meta-data android:name="APMS_SET_NOTI_SOUND" android:resource="@raw/${ring_file_name}"/>

3. Style 추가

<!-- push popup theme -->
<style name="push_popup_theme" parent="android:Theme.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

4. apms.properties 파일 설정

# APMS App Key & API Server Url Setting
# GCM발송을 위한 앱의 projectId로 GCM의 pushToken을 가져오는데 사용됩니다.
gcm_project_id=${Google_Project_Number}

# APMS Admin Web에서 앱 생성 시 발급되는 key입니다.
app_key=${App_key}

# APMS Msg-Api Url을 의미합니다.
api_server_url=${Msg_Api_Url}

# Private Server Setting
# mqtt의 사용여부를 의미합니다. ("Y":사용, "N":사용하지 않음)
mqtt_flag=${mqtt_flag}

# private server와 연동 시 필요한 server url을 의미합니다. 
# 반드시 다음과 같이 protocol, url, port를 전부 입력해주셔야 합니다. (사용하지 않을시에는 공백처리)
mqtt_server_url_ssl=${mqtt_ssl_url}
mqtt_server_url_tcp=${mqtt_tcp_url}

# private server와의 keep alive time을 의미합니다. 단위는 초(second)입니다.
# (KeepAlive Total Time : Keep alive time + Ramdom Time(2~4min))
mqtt_server_keepalive=${mqtt_keepalive}

# DEBUG MODE
# Logcat 관련 설정 입니다.
debug_tag=APMS
debug_flag=Y

# Service에 대한 로그를 파일로 저장 유무를 설정합니다.
debug_log_falg=Y

# APMS SETTING
# Push 수신시 화면 On/Off를 의미 합니다.
screen_wakeup_flag=Y

# Push 수신시 화면에 보여지는 시간을 의미 합니다. (단위 : ms)
push_popup_showing_time=9999999

# Push 노출을 앱 사용중에만 노출 할 것인지(디폴트값) 아니면
# 다른앱을 사용중에만 빼고 노출 할 것인지 설정값입니다. (default = N)
push_popup_showing_flag=N

# Push수신 시 출력되는 상단의 Notification을 터치 했을 때, broadcasting할 intent action을 의미합니다.
noti_receiver=${noti_receiver}

# Push수신 시 출력될 Popup Activity의 className을 의미합니다.
# (Default Class : "com.apms.sdk.push.PushPopupActivity")
push_popup_activity=${push_popup_activity}

5. Notification Bar Touch에 대한 BroadcastReceiver 작성

5.1 CustomNotiReceiverClass

5.2. Push Data