使用个推报错result=AppidError
混合开发,用到unipush.后端用的java
使用按条件发推送没问题,但是给某个cid发送消息一直报错AppidError,把手机里面libs下的文件全部删除,没用,重新获取cid还是没办法。最后的最后在个推技术的提示下,发现自己一直在用真机调试,必须用个推平台登记的应用参数重新云端打包才行。
后端代码如下
@Component
@Data
@ConfigurationProperties(prefix = "getui")
public class GeTuiConfig {
private String appId;
private String appKey;
private String masterSecret;
}
@Configuration
public class PullInit {
@Autowired
private GeTuiConfig geTui;
@Bean
public IGtPush init(){
IGtPush pushclient = new IGtPush(geTui.getAppKey(), geTui.getMasterSecret());
return pushclient;
}
}
public String pushToSingle(IGtPush push,String cid,String title,String content,String funcId,String funcName) {
NotificationTemplate template = pushTemplate.getNotificationTemplate(title,content,funcId,funcName);//通知模板(点击后续行为: 支持打开应用、发送透传内容、打开应用同时接收到透传 这三种行为)
// 单推消息类型
SingleMessage message = getSingleMessage(template);
Target target = new Target();
target.setAppId(geTui.getAppId());
target.setClientId(cid);
IPushResult ret = null;
try {
ret = push.pushMessageToSingle(message, target);
} catch (PushAppException e) {
e.printStackTrace();
}
if (ret != null) {
log.info(ret.getResponse().toString());
if (ret.getResponse().get("taskId")==null){
log.error("啥j8玩意儿啊");
return null;
}
return ret.getResponse().get("taskId").toString();
} else {
log.error("单推发送未知错误服务器响应异常");
return null;
}
}