Android客户端收到的数据不全


(peng619) #1

服务端发送10条数据,而Android客户端只收到5条数据


#2

免费用户,极光离线保存5条


(peng619) #3

不是离线消息啊…


#4

出现这个情况,就说明你推送这10条消息的时候,手机离线了,上线后只会收到最后5条


(peng619) #5

Android的App一直处于打开状态


#6

监听你的长连接是否正常
https://docs.jiguang.cn/jpush/client/Android/android_api/#_93

网络不稳定导致的离线也是有的

另外,你可以在测试一下,监听长连接,并同时给你的app 直接用registrationID一对一给他发消息,在长连接没有断的情况下是收到几条


(peng619) #7

好的,谢谢…


(peng619) #8

Got Response code: 400 content: {“msg_id”: 768219228, “error”: {“message”: “cannot find user by this audience”, “code”: 1011}}这是什么原因?


#9

(peng619) #10
public static void testSendPush_fromJSON() {
		ClientConfig clientConfig = ClientConfig.getInstance();
		JPushClient jpushClient = new JPushClient(masterSecret, appKey, null,
				clientConfig);
		Gson gson = new GsonBuilder().registerTypeAdapter(
				PlatformNotification.class,
				new InterfaceAdapter<PlatformNotification>()).create();
		// Since the type of DeviceType is enum, thus the value should be
		// uppercase, same with the AudienceType.
		String payloadString = "{\"platform\":{\"all\":false,\"deviceTypes\":[\"IOS\"]},\"audience\":{\"all\":false,\"targets\":[{\"audienceType\":\"TAG_AND\",\"values\":[\"tag1\",\"tag_all\"]}]},\"notification\":{\"notifications\":[{\"soundDisabled\":false,\"badgeDisabled\":false,\"sound\":\"happy\",\"badge\":\"5\",\"contentAvailable\":false,\"alert\":\"Test from API Example - alert\",\"extras\":{\"from\":\"JPush\"},\"type\":\"cn.jpush.api.push.model.notification.IosNotification\"}]},\"message\":{\"msgContent\":\"Test from API Example - msgContent\"},\"options\":{\"sendno\":1429488213,\"overrideMsgId\":0,\"timeToLive\":-1,\"apnsProduction\":true,\"bigPushDuration\":0}}";
		PushPayload payload = gson.fromJson(payloadString, PushPayload.class);
		try {
			PushResult result = jpushClient.sendPush(payload);
			LOG.info("Got result - " + result);

		} catch (APIConnectionException e) {
			LOG.error("Connection error. Should retry later. ", e);
			LOG.error("Sendno: " + payload.getSendno());

		} catch (APIRequestException e) {
			LOG.error(
					"Error response from JPush server. Should review and fix it. ",
					e);
			LOG.info("HTTP Status: " + e.getStatus());
			LOG.info("Error Code: " + e.getErrorCode());
			LOG.info("Error Message: " + e.getErrorMessage());
			LOG.info("Msg ID: " + e.getMsgId());
			LOG.error("Sendno: " + payload.getSendno());
		}
	}

调用这个方法一直返回400
这是什么原因


(peng619) #11

为什么给ios的客户端发送10条都能收到,但是给Android发送10条只能收到5条?


#12

400错误对应的有几个错误,所以请捕获具体的错误码
https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#_12

说明你Android手机离线了,保留了5条离线消息
连接状态监听 https://docs.jiguang.cn/jpush/client/Android/android_api/#_93


(peng619) #13
	String payloadString = "{\"platform\":{\"all\":false,\"deviceTypes\":[\"IOS\"]},\"audience\":{\"all\":false,\"targets\":[{\"audienceType\":\"TAG_AND\",\"values\":[\"tag1\",\"tag_all\"]}]},\"notification\":{\"notifications\":[{\"soundDisabled\":false,\"badgeDisabled\":false,\"sound\":\"happy\",\"badge\":\"5\",\"contentAvailable\":false,\"alert\":\"Test from API Example - alert\",\"extras\":{\"from\":\"JPush\"},\"type\":\"cn.jpush.api.push.model.notification.IosNotification\"}]},\"message\":{\"msgContent\":\"Test from API Example - msgContent\"},\"options\":{\"sendno\":1429488213,\"overrideMsgId\":0,\"timeToLive\":-1,\"apnsProduction\":true,\"bigPushDuration\":0}}";

这句话的参数是什么意思


#14

推送通知给设置过tag1和tag_all的iOS平台(生产环境)。

详细了解请看API文档
https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/


(peng619) #15

Android在线啊,那为什么ios能全部收到?


#16

请给我提供你Android只收到5条消息的 10条消息的msgid,和你这个Android设备的registrationID(必须必须提供)