cn.jpush.api.JPushClient Java Examples
The following examples show how to use
cn.jpush.api.JPushClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPushUtil.java From anyline with Apache License 2.0 | 6 votes |
public static JPushUtil getInstance(String key){ if(BasicUtil.isEmpty(key)){ key = "default"; } JPushUtil util = instances.get(key); if(null == util){ util = new JPushUtil(); JPushConfig config = JPushConfig.getInstance(key); util.config = config; ClientConfig clientConfig; clientConfig = ClientConfig.getInstance(); clientConfig.setApnsProduction(false); clientConfig.setTimeToLive(60 * 60 * 24); util.client = new JPushClient(config.MASTER_SECRET, config.APP_KEY, null, clientConfig); instances.put(key, util); } return util; }
Example #2
Source File: ApiBootMessagePushJiGuangServiceImpl.java From api-boot with Apache License 2.0 | 5 votes |
/** * execute push message * * @param messagePushBody request body * @throws ApiBootException ApiBoot Exception */ @Override public void executePush(MessagePushBody messagePushBody) throws ApiBootException { try { // push client config PushClientConfig pushClientConfig = getCurrentPushClient(); // jpush client JPushClient pushClient = new JPushClient(pushClientConfig.getMasterSecret(), pushClientConfig.getAppKey(), null, ClientConfig.getInstance()); PushPayload.Builder builder = PushPayload.newBuilder(); // setting platform addPlatformMeta(messagePushBody, builder); // setting tag addTagMeta(messagePushBody, builder); // setting alias // Priority is higher than tag addAliasMeta(messagePushBody.getAlias(), builder); // setting notification addNotificationMeta(builder, messagePushBody); // execute push message pushClient.sendPush(builder.build()); } catch (Exception e) { logger.error("Execute push message fail.", e); } }