Usages of

com.baidu.yun.push.auth.PushKeyPair.PushKeyPair(?, ?)
public static boolean push(String message) throws PushClientException, PushServerException { PushKeyPair pair = new PushKeyPair(APIKEY, SECREKEY); BaiduPushClient pushClient = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); try { PushMsgToAllRequest request = new PushMsgToAllRequest().addMsgExpires(new Integer(3600)).addMessageType(0) .addMessage(message) .addSendTime(System.currentTimeMillis() / 1000 + 70).addDeviceType(3); pushClient.pushMsgToAll(request); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
private static void init() { // PushKeyPair pushKeyPair = new PushKeyPair(BaiduPushConfig.APIKEY, // BaiduPushConfig.SECRETKEY); PushKeyPair pushKeyPair = new PushKeyPair(APIKEY, SECRETKEY); pushClient = new BaiduPushClient(pushKeyPair, BaiduPushConstants.CHANNEL_REST_URL); pushClient.setChannelLogHandler(new YunLogHandler() { @Override public void onHandle(YunLogEvent event) { System.out.println(event.getMessage()); } }); }
@PostConstruct private void init(){ PushKeyPair pair = new PushKeyPair(apiKey,secretKey); client = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); }
private PushKeyPair pair; // code omitted ... private Push() { pair = new PushKeyPair(API_KEY, SECRET_KEY); pushClient = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); }
private PushKeyPair pair; // code omitted ... private Push() { pair = new PushKeyPair(API_KEY, SECRET_KEY); pushClient = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); }
/** * ��������������� * @return */ private static BaiduPushClient initPushClient(){ // 1. get apiKey and secretKey from developer console PushKeyPair pair = null; pair = new PushKeyPair(apiKey, secretKey); // 2. build a BaidupushClient object to access released interfaces BaiduPushClient pushClient = new BaiduPushClient(pair,CHANNEL_REST_URL); // 3. register a YunLogHandler to get detail interacting information pushClient.setChannelLogHandler(new YunLogHandler() { public void onHandle(YunLogEvent event) { System.out.println(event.getMessage()); } }); return pushClient; }
@Override public void afterPropertiesSet() throws Exception { String apiKey = configInfo.getBaidu_push_apiKey() ; String secretKey = configInfo.getBaidu_push_secretKey() ; PushKeyPair pair = new PushKeyPair(apiKey, secretKey); // 2. ������BaiduPushClient���������SDK������ client = new BaiduPushClient(pair,BaiduPushConstants.CHANNEL_REST_URL); // 3. ������YunLogHandler������������������������������������ client.setChannelLogHandler(new YunLogHandler() { @Override public void onHandle(YunLogEvent event) { System.out.println(event.getMessage()); } }); }
/** * ���������������������. */ private static BaiduPushClient getPushClient() { PushKeyPair pair = new PushKeyPair(PushMetaData.API_KEY, PushMetaData.SECRET_KEY); // 2. build a BaidupushClient object to access released interfaces BaiduPushClient pushClient = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); // 3. register a YunLogHandler to get detail interacting information // in this request. pushClient.setChannelLogHandler(new YunLogHandler() { @Override public void onHandle(YunLogEvent event) { LOG.debug(event.getMessage()); } }); return pushClient; }
/** * @param jsonContent ������{"title":"������������(������)","description":"������������"} * @param channelId ������������������������������,���������sys_user���mobile * @return * @throws PushClientException * @throws PushServerException */ public static boolean push(String jsonContent, String channelId) throws PushClientException, PushServerException { PushKeyPair pair = new PushKeyPair(APIKEY, SECREKEY); BaiduPushClient pushClient = new BaiduPushClient(pair, BaiduPushConstants.CHANNEL_REST_URL); try { PushMsgToSingleDeviceRequest request = new PushMsgToSingleDeviceRequest(). addChannelId(channelId). addMsgExpires(new Integer(3600)). //���������������������������,���������,������3600*5. addMessageType(0). //������������������,0������������������,1������������,���������0. addMessage(jsonContent). addDeviceType(3); //���������������������deviceType => 1 for web, 2 for pc, pushClient.pushMsgToSingleDevice(request); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
/** * ��������������� * @return */ private static BaiduPushClient initPushClient(){ // 1. get apiKey and secretKey from developer console PushKeyPair pair = null; pair = new PushKeyPair("Aa39yzDCHnK5GhTAxyVXndnI", "TkhqYMbPiudSsZtFyBWt0ke3aVWNbWZb"); // 2. build a BaidupushClient object to access released interfaces BaiduPushClient pushClient = new BaiduPushClient(pair,"api.tuisong.baidu.com"); // 3. register a YunLogHandler to get detail interacting information pushClient.setChannelLogHandler(new YunLogHandler() { @Override public void onHandle(YunLogEvent event) { System.out.println(event.getMessage()); } }); return pushClient; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes