即时通信 IM 的终端用户需要随时都能够得知最新的消息,而由于移动端设备的性能与电量有限,当 App 处于后台时,为了避免维持长连接而导致的过多资源消耗,即时通信 IM 推荐您使用各厂商提供的系统级推送通道来进行消息通知,系统级的推送通道相比第三方推送拥有更稳定的系统级长连接,可以做到随时接受推送消息,且资源消耗大幅降低。
即时通信 IM 支持小米推送、华为推送、魅族推送、vivo 推送、OPPO 推送以及 Google FCM 推送,即时通信 IM Demo 中使用的厂商通道由 移动推送 TPNS 统一提供和维护。当您需要集成离线推送功能时,您可通过集成 移动推送 TPNS 服务或集成所需厂商的离线推送服务实现。
目前支持的厂商通道如下:
说明:如您需提升推送的抵达率,或进行多样化推送,推荐安装 移动推送 TPNS 的 SDK 体验完整的推送服务。若您同时使用即时通信 IM 和 移动推送 TPNS,则无需重复集成厂商通道。
推送通道 | 系统要求 | 条件说明 |
---|---|---|
小米推送 | MIUI | 使用小米推送,添加依赖:implementation 'com.tencent.tpns:xiaomi:1.2.1.2-release' |
华为推送 | EMUI | 使用华为推送,添加依赖:implementation 'com.tencent.tpns:huawei:1.2.1.2-release' 和 implementation 'com.huawei.hms:push:5.0.2.300' |
Google FCM 推送 | Android 4.1 及以上 | 手机端需安装 Google Play Services 且在中国大陆地区以外使用。添加依赖:implementation 'com.google.firebase:firebase-messaging:20.2.3' |
魅族推送 | Flyme | 使用魅族推送,添加依赖:implementation 'com.tencent.tpns:meizu:1.2.1.2-release' |
OPPO 推送 | ColorOS | 并非所有 OPPO 机型和版本都支持使用 OPPO 推送。使用 OPPO 推送,添加依赖:implementation 'com.tencent.tpns:oppo:1.2.1.2-release' |
vivo 推送 | FuntouchOS | 并非所有 vivo 机型和版本都支持使用 vivo 推送。使用 vivo 推送,添加依赖:implementation 'com.tencent.tpns:vivo:1.2.1.2-release' |
这里的离线是指在没有退出登录的情况下,应用被系统或者用户关闭。在这种情况下,如果还想收到 IM SDK 的消息提醒,可以集成即时通信 IM 离线推送。
注意:
- 对于已经退出登录(主动登出或者被踢下线)的用户,不会收到任何消息通知。
- 对于小米和华为厂商,如果在厂商开发者官网配置了 ChannelID,需要在 即时通信 IM 控制台 配置同样的 ChannelID,否则可能推送不成功;不配置会受限频影响。
实现离线消息推送的过程如下:
当客户端 App 在即时通信 IM 没有退出登录的情况下被系统或者用户 kill 时,即时通信 IM 服务端会将其他账号发来的消息通过厂商的通道推送下去。
打开 小米开放平台官网 进行注册并通过开发者认证。登录小米开放平台的管理控制台,选择【应用服务】>【PUSH服务】,创建小米推送服务应用,记录主包名
、AppID
、AppSecret
信息。
登录腾讯云 即时通信 IM 控制台,单击目标应用卡片,进入应用的基础配置页面,单击【Android平台推送设置】区域的【添加证书】。根据 步骤1 中获取的信息设置以下参数:
ID
。证书信息保存后10分钟内生效。MiPushClient.registerPush
来对小米推送服务进行初始化,注册成功后您将在自定义的 BroadcastReceiver
的 onReceiveRegisterResult
中收到注册结果。其中 regId
为当前设备上当前 App 的唯一标识。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 regId 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过小米推送通知到用户端。
您可以选择点击通知栏消息后打开应用、打开网页或打开应用内指定界面。
设置为点击通知栏消息打开应用时,会回调小米的 onNotificationMessageClicked 方法,App 可以在此方法中自行处理打开应用。
您需要在 添加证书 时选择【打开网页】并输入以http://
或https://
开头的网址,例如https://cloud.tencent.com/document/product/269
。
在 manifest 中配置需要打开的 Activity 的intent-filter
,示例代码如下,可以参考 Demo 的 AndroidManifest.xml:
<activity
android:name="com.tencent.qcloud.tim.demo.chat.ChatActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="com.tencent.qcloud.tim"
android:path="/detail"
android:scheme="pushscheme" />
</intent-filter>
</activity>
获取 intent URL,方式如下:
Intent intent = new Intent(this, ChatActivity.class);
intent.setData(Uri.parse("pushscheme://com.tencent.qcloud.tim/detail"));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
Log.i(TAG, "intentUri = " + intentUri);
// 打印结果
intent://com.tencent.qcloud.tim/detail#Intent;scheme=pushscheme;launchFlags=0x4000000;component=com.tencent.qcloud.tim.tuikit/com.tencent.qcloud.tim.demo.chat.ChatActivity;end
在 添加证书 时选择【打开应用内指定界面】并输入上述打印结果。
添加证书 时设置【点击通知后】为【打开应用】或【打开应用内指定界面】操作才支持透传自定义内容。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中的 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
若 添加证书 时设置【点击通知后】的操作为【打开应用】,当点击通知栏的消息时,会触发小米推送 SDK 的 onNotificationMessageClicked(Context context, MiPushMessage miPushMessage)
回调,自定义内容可以从 miPushMessage
中获取,可以参考 XiaomiMsgReceiver.java 的解析实现。
Map extra = miPushMessage.getExtra();
String extContent = extra.get("ext");
若 添加证书 时设置【点击通知后】的操作为【打开应用内指定界面】,封装消息的 MiPushMessage
对象通过 Intent
传到客户端,客户端在相应的 Activity
中获取自定义内容,可以参考 OfflineMessageDispatcher.java 类的 parseOfflineMessage(Intent intent) 方法实现。
Bundle bundle = getIntent().getExtras();
MiPushMessage miPushMessage = (MiPushMessage)bundle.getSerializable(PushMessageHelper.KEY_MESSAGE);
Map extra = miPushMessage.getExtra();
String extContent = extra.get("ext");
打开 华为开发者联盟官网 进行注册并通过开发者认证。进入管理中心,选择【应用服务】>【开发服务】>【PUSH】,创建华为推送服务应用。记录包名
、APP ID
、APP SECRET
信息。
登录腾讯云 即时通信 IM 控制台,单击目标应用卡片,进入应用的基础配置页面,单击【Android平台推送设置】区域的【添加证书】。根据 步骤1 中获取的信息设置以下参数:
Activity
类名,用作华为桌面应用角标显示,请参考华为推送服务开发文档中的“桌面角标”说明。ID
。证书信息保存后10分钟内生效。HmsInstanceId.getToken
接口向服务端请求应用的唯一标识 Push Token,Push Token
为当前设备上当前 App 的唯一标识。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 Push Token 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过华为推送通知到用户端。
您可以选择点击通知栏消息后打开应用、打开网页或打开应用内指定界面。
默认为点击通知栏消息打开应用。
您需要在 添加证书 时选择【打开网页】并输入以http://
或https://
开头的网址,例如https://cloud.tencent.com/document/product/269
。
在 manifest 中配置需要打开的 Activity 的intent-filter
,示例代码如下,可以参考 Demo 的 AndroidManifest.xml:
<activity
android:name="com.tencent.qcloud.tim.demo.chat.ChatActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="com.tencent.qcloud.tim"
android:path="/detail"
android:scheme="pushscheme" />
</intent-filter>
</activity>
获取 intent URL,方式如下:
Intent intent = new Intent(this, ChatActivity.class);
intent.setData(Uri.parse("pushscheme://com.tencent.qcloud.tim/detail"));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
Log.i(TAG, "intentUri = " + intentUri);
// 打印结果
intent://com.tencent.qcloud.tim/detail#Intent;scheme=pushscheme;launchFlags=0x4000000;component=com.tencent.qcloud.tim.tuikit/com.tencent.qcloud.tim.demo.chat.ChatActivity;end
在 添加证书 时选择【打开应用内指定界面】并输入上述打印结果。
注意:由于华为推送的兼容性问题,透传内容只能在部分 EUI10+ 的设备上收到。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
Activity
中获取自定义内容,可以参考 OfflineMessageDispatcher.java 类的 parseOfflineMessage(Intent intent) 方法实现。Bundle bundle = getIntent().getExtras();
String value = bundle.getString("ext");
打开 OPPO PUSH 服务开启指南 开通 PUSH 服务。在 OPPO 推送平台 >【配置管理】>【应用配置】页面,您可以查看详细的应用信息,记录 AppId
、AppKey
、AppSecret
和MasterSecret
信息。
按照 OPPO 官网要求,在 OPPO Android 8.0 及以上系统版本必须配置 ChannelID,否则推送消息无法展示。您需要先在 App 中创建对应的 ChannelID(例如 tuikit
):
public void createNotificationChannel(Context context) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "oppotest";
String description = "this is opptest";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel("tuikit", name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
登录腾讯云 即时通信 IM 控制台,单击目标应用卡片,进入应用的基础配置页面,单击【Android平台推送设置】区域的【添加证书】。根据 步骤1 中获取的信息设置以下参数:
ID
。证书信息保存后10分钟内生效。HeytapPushManager.register(…)
初始化 Opush 推送服务。ICallBackResultService
的onRegister
回调方法中得到regId
,regId
为当前设备上当前 App 的唯一标识。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 regId 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过 OPPO 推送通知到用户端。
您可以选择点击通知栏消息后打开应用、打开网页或打开应用内指定界面。
默认为点击通知栏消息打开应用。
您需要在 添加证书 时选择【打开网页】并输入以http://
或https://
开头的网址,例如https://cloud.tencent.com/document/product/269
。
打开应用内指定界面有以下几种方式:
Activity(推荐)
该方式比较简单,填入打开的 Activity 的完整类名即可,例如 com.tencent.qcloud.tim.demo.SplashActivity
Intent action
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
android.intent.action.VIEW
。添加证书 时设置【点击通知后】为【打开应用】或【打开应用内指定界面】操作支持透传自定义内容。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中的 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
当点击通知栏的消息时,客户端在启动的 Activity
中获取自定义内容,可以参考 OfflineMessageDispatcher.java 类的 parseOfflineMessage(Intent intent) 方法实现。
Bundle bundle = intent.getExtras();
Set<String> set = bundle.keySet();
if (set != null) {
for (String key : set) {
// 其中 key 和 value 分别为发送端设置的 extKey 和 ext content
String value = bundle.getString(key);
Log.i("oppo push custom data", "key = " + key + ":value = " + value);
}
}
vivo 开放平台官网 进行注册并通过开发者认证。登录其开放平台的管理中心,选择【消息推送】>【创建】>【测试推送】,创建 vivo 推送服务应用。记录APP ID、APP key和APP secret信息。
登录腾讯云 即时通信 IM 控制台,单击目标应用卡片,进入应用的基础配置页面,单击【Android平台推送设置】区域的【添加证书】。根据 步骤1 中获取的信息设置以下参数:
PushClient.getInstance(getApplicationContext()).initialize()
来对 vivo 推送服务进行初始化,并调用 PushClient.getInstance(getApplicationContext()).turnOnPush()
启动推送,成功后您将在自定义的 BroadcastReceiver
的 onReceiveRegId
中收到 regId
,regId
为当前设备上当前 App 的唯一标识。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 regId 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过 vivo 推送通知到用户端。
您可以选择点击通知栏消息后打开应用、打开网页或打开应用内指定界面。
默认为点击通知栏消息打开应用。
您需要在 添加证书 时选择【打开网页】并输入以http://
或https://
开头的网址,例如https://cloud.tencent.com/document/product/269
。
在 manifest 中配置需要打开的 Activity 的intent-filter
,示例代码如下,可以参考 Demo 的 AndroidManifest.xml:
<activity
android:name="com.tencent.qcloud.tim.demo.chat.ChatActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data
android:host="com.tencent.qcloud.tim"
android:path="/detail"
android:scheme="pushscheme" />
</intent-filter>
</activity>
获取 intent URL,方式如下:
Intent intent = new Intent(this, ChatActivity.class);
intent.setData(Uri.parse("pushscheme://com.tencent.qcloud.tim/detail"));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
Log.i(TAG, "intentUri = " + intentUri);
// 打印结果
intent://com.tencent.qcloud.tim/detail#Intent;scheme=pushscheme;launchFlags=0x4000000;component=com.tencent.qcloud.tim.tuikit/com.tencent.qcloud.tim.demo.chat.ChatActivity;end
在 添加证书 时选择【打开应用内指定界面】并输入上述打印结果。
添加证书 时设置【点击通知后】为【打开应用】或【打开应用内指定界面】操作支持透传自定义内容。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中的 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
点击通知栏的消息时,会触发 vivo 推送 SDK 的 onNotificationMessageClicked(Context context, UPSNotificationMessage upsNotificationMessage)
回调,自定义内容可以从 upsNotificationMessage
中获取,可以参考 VIVOPushMessageReceiverImpl.java 的解析实现。
Map<String, String> paramMap = upsNotificationMessage.getParams();
String extContent = paramMap.get("ext");
打开 魅族开放平台官网 进行注册并通过开发者认证。登录其控制台,选择【开发服务】>【Flyme推送】,创建魅族推送服务应用。记录应用包名
、App ID
、App Secret
信息。
登录腾讯云 即时通信 IM 控制台,单击目标应用卡片,进入应用的基础配置页面,单击【Android平台推送设置】区域的【添加证书】。根据 步骤1 中获取的信息设置以下参数:
ID
。证书信息保存后10分钟内生效。PushManager.register
来对魅族推送服务进行初始化,注册成功后您将在自定义的 BroadcastReceiver
的 onRegisterStatus
中收到注册结果。其中 registerStatus.getPushId()
为当前设备上当前 App 的唯一标识。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 PushId 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过魅族推送通知到用户端。
您可以选择点击通知栏消息后打开应用、打开网页或打开应用内指定界面。
默认为点击通知栏消息打开应用。
您需要在 添加证书 时选择【打开网页】并输入以http://
或https://
开头的网址,例如https://cloud.tencent.com/document/product/269
。
您需要在 添加证书 时选择【打开应用内指定界面】并输入需要打开的 Activity 的完整类名,例如 com.tencent.qcloud.tim.demo.chat.ChatActivity
。
添加证书 时设置【点击通知后】为【打开应用】或【打开应用内指定界面】操作才支持透传自定义内容。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中的 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
点击通知栏的消息时,会触发魅族推送 SDK 的 onNotificationClicked(Context context, MzPushMessage mzPushMessage)
回调 ,自定义内容可以从 mzPushMessage
中获取。
String extContent = mzPushMessage.getSelfDefineContentString();
另外,客户端也可以在打开的 Activity
中获取自定义内容,可以参考 OfflineMessageDispatcher.java 类的 parseOfflineMessage(Intent intent) 方法实现。
Bundle bundle = getIntent().getExtras();
String extContent = bundle.getString("ext");
ID
。证书信息保存后10分钟内生效。FirebaseInstanceId.getInstance().getInstanceId()
后,在回调里获取当前 App 的唯一标识 token。当登录 IM SDK 成功后,需要调用 setOfflinePushConfig 将证书 ID 和 token 上报到即时通信 IM 服务端。成功上报证书 ID 及 regId 后,即时通信 IM 服务端会在该设备上的即时通信 IM 用户 logout 之前、App 被 kill 之后将消息通过 FCM 推送通知到用户端。
步骤1:发送端设置自定义内容
在发消息前设置每条消息的通知栏自定义内容。
下面是 Android 端简单示例,也可以参考 TUIKit 中 ChatManagerKit.java 类的 sendMessage() 方法中对应的逻辑:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("extKey", "ext content");
} catch (JSONException e) {
e.printStackTrace();
}
String extContent = jsonObject.toString();
V2TIMOfflinePushInfo v2TIMOfflinePushInfo = new V2TIMOfflinePushInfo();
v2TIMOfflinePushInfo.setExt(extContent.getBytes());
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, userID, null, V2TIMMessage.V2TIM_PRIORITY_DEFAULT, false, v2TIMOfflinePushInfo, new V2TIMSendCallback<V2TIMMessage>() {
@Override
public void onError(int code, String desc) {}
@Override
public void onSuccess(V2TIMMessage v2TIMMessage) {}
@Override
public void onProgress(int progress) {}
});
服务端示例请参见 OfflinePushInfo 的格式示例
步骤2:接收端获取自定义内容
当点击通知栏的消息时,客户端在相应的 Activity
中获取自定义内容,可以参考 OfflineMessageDispatcher.java 类的 parseOfflineMessage(Intent intent) 方法实现。
Bundle bundle = getIntent().getExtras();
String value = bundle.getString("ext");
请在调用 sendMessage 发送消息的时候使用 V2TIMOfflinePushInfo
中的 setIOSSound 接口来设置 iOS 端的推送声音。
请在调用 sendMessage 发送消息的时候使用 V2TIMOfflinePushInfo
中的 setTitle 和 setDesc 接口来分别设置通知栏消息的标题和内容。
目前大部分厂商都不支持离线推送声音的设置,因此 IM SDK 暂时不支持。
OPPO 手机收不到推送一般有以下几种情况:
自定义消息的离线推送和普通消息不太一样,自定义消息的内容我们无法解析,不能确定推送的内容,所以默认不推送,如果您有推送需求,需要您在 sendMessage 的时候设置 offlinePushInfo 的 desc 字段,推送的时候会默认展示 desc 信息。
org域名 怎么购买?org 域名 购买,分为新注册的org域名,和购买已注册的org域名...
预测与异常检测函数通过预测时序曲线、寻找预测曲线和实际曲线之间误差的Ksigma...
云备份所提供的接口均为CBR接口,您可以通过这些接口完整的使用云备份的所有功能...
本文转载自微信公众号「BAT的乌托邦」,作者YourBatman。转载本文请联系BAT的乌...
对于业务分析的不同阶段,企业需要在各个步骤中处理大量数据。根据工作流程的阶...
日常编写数据加工任务 主要的方法就是使用SQL。第一是因为自己对SQL掌握的比较好...
本文转载自微信公众号「小明菜市...
本文整理自 360 政企安全集团的大数据工程师苏军以及刘佳在 Flink Forward Asia ...
【中国,深圳,2020年7月28日】今日,主题为智慧深圳,进而有为的华为云与计算城...
工业发展进入到21世纪之后,随着物联网、云计算和大数据等新兴技术的迅速发展,...