Browse Source

提交抢单工短信登录/推送信息修改/clientId绑定

cangku
Houpn 3 years ago
parent
commit
74066b817f
  1. 39
      hiver-core/src/main/java/cc/hiver/core/serviceimpl/JPushServiceImpl.java

39
hiver-core/src/main/java/cc/hiver/core/serviceimpl/JPushServiceImpl.java

@ -0,0 +1,39 @@
package cc.hiver.core.serviceimpl;
import cc.hiver.core.service.JPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.notification.Notification;
@Service
public class JPushServiceImpl implements JPushService {
@Autowired
private JPushClient jPushClient;
@Autowired
public JPushServiceImpl(JPushClient jPushClient) {
this.jPushClient = jPushClient;
}
@Override
public void sendPushNotification(String registrationId, String message) {
PushPayload payload = PushPayload.newBuilder()
.setPlatform(cn.jpush.api.push.model.Platform.all())
.setAudience(cn.jpush.api.push.model.audience.Audience.registrationId(registrationId))
.setNotification(Notification.alert(message))
.build();
try {
PushResult result = jPushClient.sendPush(payload);
System.out.println("Push result: " + result);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save