答:
"@type":"com.baidu.yun.push.exception.PushServerException","errorCode":30602,"errorMsg":"Request Params Not Valid, sorry your ios app not in whitelist please apply from push-support@baidu.com","requestId":2572092089,"stackTrace":[{"className":"com.baidu.yun.push.transform.PushRestResponseJsonUnmapper","fileName":"PushRestResponseJsonUnmapper.java","lineNumber":51,"methodName":"unmarshall","nativeMethod":false}
您好我也出现了这个问题,手机端用自带推送软件是可以正常接受到推送信息的。但是Java服务端推送报错。
这个是我的服务端代码:key是没有用错的。
public byte[] IOSPush(String packagename, String alias, String title, String description) {
JSONObject rt = new JSONObject();
rt.put("method", "iospush");
Appsecret _appsecret=new Appsecret();
_appsecret.setPackagename(packagename);
_appsecret.setType(false);
Appsecret appsecret=appsecretServer.findByAppId(_appsecret);
if(appsecret==null)
{
rt.put("result", false);
rt.put("msg", "不存在appid");
return rt.toString().getBytes();
}
rt.put("packageName:",appsecret.getPackagename()+" Secretkey:"+appsecret.getSecretkey()+" :"+appsecret.getApikey());
String apiKey = appsecret.getApikey();
String secretKey = appsecret.getSecretkey();
PushKeyPair pair = new PushKeyPair(apiKey, secretKey);
BaiduPushClient pushClient = new BaiduPushClient(pair,
BaiduPushConstants.CHANNEL_REST_URL);
try {
JSONObject aps = new JSONObject();
aps.put("alert",title+": "+ description);
aps.put("badge", "1");
JSONObject notification = new JSONObject();
notification.put("aps", aps);
notification.put("key1","value1");
notification.put("key2","value2");
rt.put("notification", notification);
PushMsgToSmartTagRequest request = new PushMsgToSmartTagRequest()
.addSelector(alias)
.addMsgExpires(new Integer(3600))
.addMessageType(1)
.addMessage(notification.toString())
.addDeviceType(4)
.addDeployStatus(1)
;
PushMsgToSmartTagResponse response = pushClient
.pushMsgToSmartTag(request);
} catch (PushClientException e) {
rt.put("result", false);
rt.put("msg",e );
return rt.toString().getBytes();
} catch (PushServerException e) {
rt.put("result", false);
rt.put("msg", e);
return rt.toString().getBytes();
}