测试了下在控制台发送推送,应用进程杀死后也能收到推送。但是对方应用发送过来的消息收不到离线消息推送。测试机三星GALAXY S5 小米4 vivo Y33 都收不到
初始化操作
AVOSCloud.initialize(getApplicationContext(),"yiq7Vj8hWhKldyg0bD19BNVo-gzGzoHsz","T5pKTADBUiUIKEF9QGDLEW2Q");
AVIMMessageManager.registerAVIMMessageType(UhsShareMessage.class);
AVOSCloud.setDebugLogEnabled(true);
AVIMClient.setOfflineMessagePush(true);
PushService.setDefaultPushCallback(this, LoginActivity.class);
AVInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(AVException e) {
if (e == null) {
// 保存成功
installationId = AVInstallation.getCurrentInstallation().getInstallationId();
// 关联 installationId 到用户表等操作……
} else {
// 保存失败,输出错误信息
}
}
});
添加离线消息内容
AVIMMessageOption messageOption = new AVIMMessageOption();
messageOption.setPushData(str);
mConversation.sendMessage(msg, messageOption, new AVIMConversationCallback() {
@Override
public void done(AVIMException e) {
if (e == null) {
Log.e("info", "发送成功");
getChatDetails();
} else {
Log.e("info", "发送" + e.getMessage());
}
}
});
注册服务
service android:name="com.avos.avoscloud.PushService"
receiver android:name="com.avos.avoscloud.AVBroadcastReceiver"
intent-filter
action android:name="android.intent.action.BOOT_COMPLETED"
action android:name="android.intent.action.USER_PRESENT"
action android:name="android.net.conn.CONNECTIVITY_CHANGE"
intent-filter
receiver
-
创建时间
17年4月10日
-
最后回复
17年11月14日
-
7
回复
-
3.7K
浏览
-
4
用户