Live Operation 服务
Live Operation 服务(简称 LiveOps) 会支持如下两种功能。
A. [定向推送功能] 筛选出应用里的用户,可以向目标用户发送推送信息。
B. [定向弹窗通知功能] 需要对用户发布通知时,可以弹出通知栏告知各种内容。
通过 LiveOps 对接,可以使用并运营更提升的推送功能、向用户通知活动内容的弹窗功能。
需要更详情的 LiveOps 服务介绍及适用方式,请参考如下文档。
若 LiveOps 对接上所需要帮忙的话,请联系至如下邮件地址。
技术咨询 - 中国事业部 (china@igaworks.com)
注意事项
- 为了对接 LiveOps 服务,需要先 Google Play Services 对接。 [Google Play Services 设置]
- 为了对接 LiveOps 服务,需包含最新版本的 android-support-v4.jar (需求版本为 ver26 以上) [Google 详情文档]
- 在 Eclipse 开发环境上可以适用 FCM 的参考文档,正在准备中。请稍等
SDK 下载及安装
下载资源 (Download Library)
通过如下链接,请下载并解压 Eclipse 专用的 LiveOps Android Library。
[LiveOps Eclipse 专用 Android Library] *若无法下载的话,先打开 vpn 再尝试。
添加资源 (Add Library)
已解压的文件中,把 .jar 文件复制到 Project 里的 libs 文件。
添加图片资源 (Add Image Resource)
解压后的文件中,在 drawble 文件里包含的所有图片资源复制到 Android Project 上的 /res/drawble 文件。
设置 Android Manifest
为了使用 LiveOps 支持的服务,需在 AndroidManifest.xml 上添加如下内容。
添加 App Key & Hash Key
IGAWorks 官网上注册并登录应用完成后,在 <application></application> 标签上输入相应的 App Key & Hash Key。
<application>
...
<meta-data android:name="igaworks_app_key" android:value="请输入官网上确认的 App Key" />
<meta-data android:name="igaworks_hash_key" android:value="请输入官网上确认的 Hash Key" />
...
</application>
添加 Permission
在 <manifest></manifest> 标签上添加如下必备 Permission。
<manifest>
...
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- LiveOps v1.3.6 版本以上时不需添加如下 Permission。 -->
<uses-permission android:name="android.permission.GET_TASKS"/>
<!-- C2DM Permission -->
<permission android:name="MY_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel = "signature"/>
<uses-permission android:name="MY_PACKAGE_NAME.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
...
</manifest>
+ 在 C2DM Permission 设置的 MY_PACKAGE_NAME 中,输入在对接中的 Package Name。
添加 Receiver
在 <application></application> 标签上登录 LiveOps 所需的必备 Receiver 和 Service。
<!-- IGAWorks GCM Broadcast Receiver -->
<receiver android:name="com.igaworks.liveops.pushservice.LiveOpsGCMBroadcastReceiver"
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="MY_PACKAGE_NAME" />
</intent-filter>
</receiver>
<!-- IGAWorks Push Service -->
<service android:enabled="true" android:name="com.igaworks.liveops.pushservice.GCMIntentService" />
<!-- Client Push App Receiver -->
<receiver android:name="com.igaworks.liveops.pushservice.LiveOpsReceiver"
android:permission="MY_PACKAGE_NAME.permission.C2D_MESSAGE">
<intent-filter>
<action android:name="com.igaworks.liveops.pushservice.CLIENT_PUSH_RECEIVE"/>
</intent-filter>
</receiver>
+ Receiver 设置的 MY_PACKAGE_NAME 中,输入在对接中的 Package Name。
OREO 版本的支持 API
在 <manifest></manifest> 标签上登录如下支持 Android 8.0 OREO 版本的 API。
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="26"/>
设置 Proguard
在 Android Studio 里的 app/proguard-rules.pro 文件上添加 IGAW SDK 的混淆例外处理设置。
##---------------Begin: proguard configuration for Igaworks Common ----------
-keep class com.igaworks.** { *; }
-dontwarn com.igaworks.**
##---------------End: proguard configuration for Igaworks Common ----------
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.igaworks.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.igaworks.adbrix.model.** { *; }
##---------------End: proguard configuration for Gson ----------
注意!!! Eclipse Project 上需要混淆处理时,在 Project/proguard-project.txt 文件上直接修改相应内容。
基本对接
Session Tracking : 自动
<application
android:name="com.igaworks.IgawDefaultApplication"
... 中略 ...
>
</application>
使用自己的 application class 情况时,
<!-- AndroidManifest.xml -->
<application
android:name="PACKAGE_NAME.YourCustomApplication"
... 中略 ...
>
</application>
/* YourCustomApplication.java */
public class YourCustomApplication extends Application{
@Override
public void onCreate(){
super.onCreate();
IgawCommon.autoSessionTracking(YourCustomApplication.this);
// 在 application class 上除了 autoSessionTracking API 外,不需调用任何 adbrix API。
}
}
Session Tracking : 手动
@Override
protected void onResume() {
super.onResume();
IgawCommon.startSession(MainActivity.this);
}
@Override
protected void onPause() {
super.onPause();
IgawCommon.endSession();
}
推送对接 : 服务器
初始化 SDK
- IgawCommon.setUserId(String userId);
- IgawLiveOps.initialize(Context context);
- IgawLiveOps.resume(Context context);
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//必须得设置用户识别码。
IgawCommon.setUserId(MainActivity.this,"user10001");
//初始化 LiveOps SDK。
IgawLiveOps.initialize(MainActivity.this);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
IgawLiveOps.resume(MainActivity.this);
}
}
输入用户识别码 (User Id)
用户识别码是为了 LiveOps 判断用户所需的一种信息。
注意事项
- 每一用户只有一个固定的用户识别码。而且不可以使用变量的值。
- 不可以包含个人信息。(如邮件、性别、电话号码、可识别的 User ID 等)
- 若包含中文、韩文、空白及特殊字符等时,必须 URL 进行编码后使用。
- 需在 IgawLiveOps.initialize API 调用前时点上设置。
请留意以上注意事项,输入用户识别码。
IgawCommon.setUserId(getApplicationContext(),"user10001");
对接 DeepLink / 服务器推送
种类 | 形式 |
URL (Http Type) | http://www.igaworks.com |
URL (Custom Scheme Type) | myApp://activity.com |
Json Type | {"key":"value", "igaworks":"sample"} |
- URL (http Type) 及 Json
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
IgawCommon.setUserId(MainActivity.this"userid_123123123");
IgawLiveOps.initialize(MainActivity.this);
//通过 onNewIntent Listener 传达 intent。
onNewIntent(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
/* 根据 DeepLink Type,请参考如下内容进行实现。 */
/* 1. App Scheme 形式(myApp://deepLinkAction) 来实现 DeepLink 功能。
*
* 通过 DeepLink 里的 App Scheme Action 进行启动。
* IgawLiveOps.onNewIntent(MainActivity.this, intent);
*/
/* 2. Json 字符串形式({“url”:”deepLinkAction”}) 来实现 DeepLink 功能。
*
* 通过 DeepLink 上接受的 Json 字符串导出后,再变更 Json Object。
* String jsonStr = intent.getStringExtra("com.igaworks.liveops.deepLink");
* JSONObject jsonObj;
* try {
* jsonObj = new JSONObject(jsonStr);
* //Json Object Parsing 后,实现需要运行的动作。
* } catch (Exception e) {
* // TODO: handle exception
* }
*/
}
}
- URL (Custom Scheme Type)
<!-- 添加 IgawLiveOpsPushMessageLauncherActivity。-->
<activity
android:name="com.igaworks.liveops.pushservice.IgawLiveOpsPushMessageLauncherActivity"
android:permission="MY_PACKAGE_NAME.permission.C2D_MESSAGE"
android:noHistory="true"/>
<!-- 设置 DeepLink 配置的 Activity。-->
<activity android:name="com.example.DeeplinkActivity">
<intent-filter>
<data android:scheme="myApp" android:host="activity.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
推送对接 : 客户端
普通客户端推送
IgawLiveOps.setNormalClientPushEvent(
this, // Application Context
1, // Delay seconds. 设置为多少秒后发推送的事项。
"Let’s play now!", // 想要传送的推送内容。
1, // Event ID, 为了取消时使用的值。
false // 设置为应用在运行中是否显示推送信息。
);
大容量客户端推送
IgawLiveOps.setBigTextClientPushEvent(
this, // Application Context
1, // Delay seconds, 设置为多少秒后发推送的事项。
"contentText", // contents
"bigContentTitle", // 普通推送内容。
"Let's play now! WoooooooW!!", // 推送中显示的大文字。
"summaryText", // 推送中显示的摘要文字。
1, // Event ID, 为了取消时使用的值。
false // 设置为应用在运行中是否显示推送信息。
);
推送对接 : 附加选项
定向目标用户
设置 Targeting Data
//IgawLiveOps.setTargetingData(Context applicationContext, final String userCustomDataKey, final Object userCustomData);
IgawLiveOps.setTargetingData(context, "purchaseCount", purchaseCount);
同步 Targeting Data
@Override
protected void onPause() {
super.onPause();
IgawLiveOps.resume();
}
手动同步
IgawLiveOps.flush(MainActivity.this);
推送接收 on/off
设置推送接收与否
- true : 接收推送信息。
- false : 拒绝推送信息。
IgawLiveOps.enableService(MainActivity.this, true);
替换推送 Icon Image
在推送服务上的 Push icon image 是在使用 Launcher Icon 上登录的 App icon image。
为了获取 Google featured 需替换图片时,可以调用 setNotificationIconStyle api 来替换图片。
//IgawLiveOps.setNotificationIconStyle(Context context, String small_icon_name, String large_icon_name, int argb);
IgawLiveOps.setNotificationIconStyle(getApplicationContext(), "ic_small_filename", "ic_large_filename", 0xFFE90F0F);
通知设置
在 Android 5.0 以上的版本上可以设置浮动通知(Heads-up notification) 和锁屏画面的通知功能。
浮动通知是在设备激活的情况下才能曝光通知的一种功能。锁屏通知是在锁屏画面上曝光通知的另一功能。
(更闲情的内容,请参考谷歌说明的相关文档。[Google Notification Guide])
调用 setNotificationOption api,可以设置浮动、锁屏通知的内容。
设置浮动通知 (priority)
- PRIORITY_MAX (int:2), 使用浮动通知
- PRIORITY_HIGH (int:1), 使用浮动通知
- PRIORITY_DEFAULT (int:0), 不使用浮动通知
- PRIORITY_LOW (int:-1), 不使用浮动通知
- PRIORITY_MIN (int:-2), 不使用浮动通知
设置锁屏画面通知 (visibility)
- VISIBILITY_SECRET (int:-1), 不使用 Lock Screen 通知
- VISIBILITY_PRIVATE (int:0), 使用不显示内容的 Lock Screen 通知
- VISIBILITY_PUBLIC (int:1), 使用 Lock Screen 中显示全体内容的通知
// public static void setNotificationOption(Context context, int priority, int visibility)
IgawLiveOps.setNotificationOption(getApplicationContext(), NotificationCompat.PRIORITY_HIGH, NotificationCompat.VISIBILITY_SECRET);
通知摘要 (InboxStyle)
将多个通知概括成一个摘要通知。Inbox Style 只适用于服务器推送。
(*客户端推送是无法获取推送 ID 的原因,不支持 Inbox Style。)
调用 setStackingNotificationOption api,设置如下想要适用的内容。
设置通知摘要 (useStacking)
- true : 使用通知摘要功能,进行曝光。
- false : 不使用通知摘要功能。
设置摘要通知曝光 (useTitleForStacking)
- true : 打开摘要通知的同时曝光题目。
- false : 打开摘要通知的同时曝光内容。
设置摘要通知的题目、内容 (ContentTitle, ContentText)
- empty : 曝光最新通知的题目及内容。
- your_custom_message : 曝光在 api 上调用的题目及内容。
设置在打开摘要通知时曝光的题目 (bigContentTitle)
- empty : 曝光 ContentTitle。
- your_custom_message : 曝光在 api 上调用的题目。
设置在打开摘要通知时的摘要内容 (bigContentSummaryText)
- empty : 不使用内容摘要。
- your_custom_message : 曝光在 api 上调用的内容。
// public static void setStackingNotificationOption(Context context, boolean useStacking, boolean useTitleForStacking, String ContentTitle, String ContentText, String bigContentTitle, String bigContentSummaryText)
IgawLiveOps.setStackingNotificationOption(getApplicationContext(), true, false, "More events are waiting for you", "See detail", "All events", "For Summary Text");


弹窗对接
为了使用 LiveOps - 弹窗服务,按照如下步骤进行初始化。
如下初始化相关 API 调用时点为 "应用启动之后"。(推荐)
输入用户识别码 (User Id)
用户识别码是为了 LiveOps 判断用户所需的一种信息。
注意事项
- 每一用户只有一个固定的用户识别码。而且不可以使用变量的值。
- 不可以包含个人信息。(如邮件、性别、电话号码、可识别的 User ID 等)
- 若包含中文、韩文、空白及特殊字符等时,必须 URL 进行编码后使用。
- 需在 requestPopupResources API 调用前时点上设置。
请留意以上注意事项,输入用户识别码。
IgawCommon.setUserId(getApplicationContext(),"user10001");
加载弹窗通知数据
调用 requestPopupResources api,加载在 LiveOps 管理页面上设置的所有弹窗相关数据。
加载弹窗数据前,必须已完成设置 '用户识别码' 。
注意事项
- 未输入用户识别码时,无法加载弹窗相关数据。
- 即使在 LiveOps 弹窗管理页面上添加新的弹窗,但是没加载弹窗数据的话,在 SDK 中无法确认新登录的弹窗内容。
请留意以上的注意事项,请加载弹窗通知数据。
//加载弹窗通知数据
IgawLiveOps.requestPopupResource(mainContext, new LiveOpsPopupResourceEventListener() {
@Override
public void onReceiveResource(boolean isReceive) {
Log.d("liveops", "isReceivePopupResource? :: " + isReceive);
}
});
曝光弹窗通知 API
调用 showPopup api,在想要显示的时点上曝光弹窗形式的通知。
弹窗中显示的内容是,在弹窗通知管理页面上设置的内容。
如下是以点击 showPopupNotiBtn 按钮时,曝光弹窗通知的示例。
Button showPopupNotiBtn;
showPopupNotiBtn = (Button)findViewById(R.id.showPopupNotiBtn);
showPopupNotiBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//曝光弹窗通知。
//showPopup(Context context, String popup_spacekey, LiveOpsDeepLinkEventListener listener);
IgawLiveOps.showPopUp(MainActivity.this, "弹窗通知 Space_Key", null);
}
});
+ 弹窗通知的 Space Key,只能在弹窗通知管理界面上才会获取。
+ LiveOpsDeepLinkEventListener 是在使用弹窗通知 DeepLink 功能时才会用的一种 api。
弹窗通知 DeepLink
使用弹窗通知上的 DeepLink 功能,可以处理更多样的弹窗动作。
Button showPopupNotiBtn;
showPopupNotiBtn = (Button)findViewById(R.id.showPopupNotiBtn);
showPopupNotiBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IgawLiveOps.showPopUp(mainContext, "弹窗通知 Space_key", new LiveOpsDeepLinkEventListener() {
@Override
public void onReceiveDeeplinkData(String deepLinkDataString) {
Log.d("liveops", "LiveOpsPopUp DeepLinkData :::: " + deepLinkDataString);
//在使用 DeepLink Data,执行后续动作。
}
});
}
});
+ 弹窗通知的 Space Key,只能在弹窗通知管理界面上才会获取。
+ DeepLink 是可以在弹窗通知管理界面上登录。
+ DeepLink 是支持 Json 形式。
弹窗通知里的用户定向
在弹窗通知界面上创建用户群,可以直接选择并曝光用户对象。
为创建用户群的各种数据,可以直接设置。
设置定向数据
为了对定向的用户上显示弹窗通知,可以直接设置 '自定义用户数据(Custom User Data)'。
自行已设置的用户数据,可以在弹窗通知管理界面上能够确认。如下是以购买次数为获取定向用户数据的示例。
//IgawLiveOps.setTargetingData(Context applicationContext, final String customUserDataKey, final Object customUserData);
IgawLiveOps.setTargetingData(MainActivity.this, "purchaseCount", purchaseCount);
+ customUserData : 输入定向用户的数据。支持 bool、int、long、float、String 形式。
+ customUserDataKey : 设置用户自定义值(User Custom Data Key)。
同步定向数据
调用 resume api,将设置的定向数据同步到 LiveOps Serve。
需在 Activity 的 onResume() 上添加像如下;
@Override
protected void onResume() {
super.onResume();
IgawLiveOps.resume(MainActivity.this);
//… 以下中略
}
弹窗通知 : 追加选项
弹窗通知 Event Listener
提供在弹窗通知上发生 Click Event 的 Listener。
- onCancelPopupBtnClick : 弹窗通知关闭事件
- onPopupClick : 弹窗通知点击事件
使用 setLiveOpsPopupEventListener api,登录及实现 Event Listener。
IgawLiveOps.setLiveOpsPopupEventListener(new LiveOpsPopupEventListener() {
@Override
public void onCancelPopupBtnClick() {
// 点击弹窗通知关闭按键
}
@Override
public void onPopupClick() {
// 弹窗通知打开事件
}
});
弹窗通知强制关闭
不需用户的点击事件,使用如下 API 可以处理强制关闭弹窗通知。
关闭目前弹窗通知
调用 destroyPopup api,强制关闭最上端的弹窗通知。
IgawLiveOps.destroyPopup();
关闭所有弹窗通知
调用 destroyAllPopups api,强制关闭所有弹窗通知。(包括等待中的弹窗数据)
IgawLiveOps.destroyAllPopups()