SDK 3.0 User Guide

文档管理

日期 更新内容 名字
2015.01.14 编辑初期版本 Yang Dong miin
2015.03.17 添加弹出框的Flag. Yang Dong miin

附件

附件名 说明 大小
google-play-services.jar GCM 关联的lib 3,416,020 byte
pms-sdk-xxxx.jar PMS lib 198,461 byte
org.eclipse.paho.client.mqttv3.1.jar 连接Private Server lib 131,045 byte
volley_201408200633.jar PMS API 通信lib 88,767 byte
pms.propreties PMS 设置文件 586 byte
version.xml 为了使用Google Play Service的version设置文件 130 byte

1. lib 应用方法

1.1 在项目里面把所有 *. jar 添加到libs文件夹

enter image description here

1.2 如下图刷新后确认

enter image description here

1.3 把'pms.properties'文件存在 assets的文件夹.

# PMS 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=PMS
debug_flag=Y
debug_log_falg=Y

# PMS 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" />
<!-- 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

<!-- pms GCM Receiver -->
<receiver
    android:name="com.pms.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

<!-- pms 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

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

2.5 添加Private Server service 以及 receiver

<!-- PMS Private RestartReceiver -->
<receiver android:name="com.pms.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>
    
<!-- PMS Private connectionChangeReceiver -->
<receiver android:name="com.pms.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.pms.sdk.push.mqtt.MQTTService"
    android:enabled="true"
    android:exported="true"
    android:label="PushService"
    android:process="${process_name}" />
    
<!-- Private PUSH Receiver -->
<receiver android:name="com.pms.sdk.push.PushReceiver" >
    <intent-filter>
        <action android:name="org.mosquitto.android.mqtt.MSGRECVD" />
        <category android:name="${project_package}" />
    </intent-filter>
</receiver>

2.6 添加Notification 设定值

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

2.7 添加Notification Icon 设定值

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

2.8 添加Push Alram Sound设置值

<meta-data android:name="PMS_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. 设置pms.properties 文件

# PMS App Key & API Server Url Setting
# 为了推送GCM的App用projectId获取GCM的pushToken.
gcm_project_id=${Google_Project_Number}

# 在PMS Admin Web里生成App是发布的key.
app_key=${App_key}

# PMS 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=PMS
debug_flag=Y

# 设置Service的log.
debug_log_falg=Y

# PMS SETTING
# 接收推送时的接收画面的On/Off.
screen_wakeup_flag=Y

# 接收推送时在画面上显示的时间(单位 : ms)
push_popup_showing_time=9999999

# 显示推送是使用当前App的时候显示(默认)
# 或者使用别的App时候是不显示(default = N)
push_popup_showing_flag=N

# 接收推送时触摸上端Notification时候要broadcasting的 intent action.
noti_receiver=${noti_receiver}

# 接收推送时显示的Popup Activity的 className.
# (Default Class : "com.pms.sdk.push.PushPopupActivity")
push_popup_activity=${push_popup_activity}

5. 设置Notification Bar Touch的 BroadcastReceiver

5.1 CustomNotiReceiverClass

5.2. Push Data