Ver código fonte

极光推送

jiangbiao 11 meses atrás
pai
commit
7078c99449

+ 32 - 0
master/src/main/java/com/ruoyi/common/jpush/JiGuangConfig.java

@@ -0,0 +1,32 @@
+//package com.ruoyi.common.jpush;
+//
+//import cn.jiguang.sdk.api.PushApi;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//
+///**极光推送配置
+// */
+//@Configuration
+//public class JiGuangConfig {
+//    /**
+//     * 极光官网-个人管理中心-appkey
+//     * https://www.jiguang.cn/
+//     */
+//    @Value("${jpush.appKey}")
+//    private String appKey;
+//
+//    /**
+//     * 极光官网-个人管理中心-点击查看-secret
+//     */
+//    @Value("${jpush.masterSecret}")
+//    private String masterSecret;
+//
+//    @Bean
+//    public PushApi pushApi() {
+//        return new PushApi.Builder()
+//                .setAppKey(appKey)
+//                .setMasterSecret(masterSecret)
+//                .build();
+//    }
+//}

+ 73 - 0
master/src/main/java/com/ruoyi/common/jpush/JiGuangPushService.java

@@ -0,0 +1,73 @@
+//package com.ruoyi.common.jpush;
+//
+//import cn.jiguang.sdk.api.PushApi;
+//import cn.jiguang.sdk.bean.push.PushSendParam;
+//import cn.jiguang.sdk.bean.push.PushSendResult;
+//import cn.jiguang.sdk.bean.push.audience.Audience;
+//import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
+//import cn.jiguang.sdk.bean.push.other.CidGetResult;
+//import cn.jiguang.sdk.constants.ApiConstants;
+//import com.alibaba.fastjson.JSON;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Service;
+//
+//import java.util.Arrays;
+//
+//@Service
+//public class JiGuangPushService {
+//    Logger log = LoggerFactory.getLogger(this.getClass());
+//
+//
+//    @Autowired
+//    private PushApi pushApi;
+//
+//    public void getCidForPush() {
+//        CidGetResult result = pushApi.getCidForPush(10);
+//        log.info("result:{}", result);
+//    }
+//
+//
+//    public void send(String title, String alert, String alias) {
+//        PushSendParam param = new PushSendParam();
+//        // 通知内容
+//        NotificationMessage.Android android = new NotificationMessage.Android();
+//        android.setAlert(alert);
+//        android.setTitle(title);
+//        NotificationMessage.Android.Intent intent = new NotificationMessage.Android.Intent();
+//        intent.setUrl("intent:#Intent;action=android.intent.action.MAIN;end");
+//
+//        android.setIntent(intent);
+//
+//        NotificationMessage notificationMessage = new NotificationMessage();
+//        notificationMessage.setAlert(alert);
+//        notificationMessage.setAndroid(android);
+//        param.setNotification(notificationMessage);
+//
+//        // 目标人群
+//        Audience audience = new Audience();
+//        audience.setAliasList(Arrays.asList(alias));
+////        audience.setRegistrationIdList(Arrays.asList("1104a89793af2cfc030", "1104a89793af2cfc030"));
+//        // 指定目标
+//        param.setAudience(audience);
+//        // 或者发送所有人
+////        param.setAudience(ApiConstants.Audience.ALL);
+//
+//        // 指定平台
+////        param.setPlatform(Arrays.asList(Platform.android, Platform.ios));
+//        // 或者发送所有平台
+//        param.setPlatform(ApiConstants.Platform.ANDROID);
+//
+//        log.info("param:{}", JSON.toJSONString(param));
+//        // 发送
+//        try {
+//            PushSendResult result = pushApi.send(param);
+//            System.out.println("Push result: " + result);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//
+//    }
+//
+//}

+ 5 - 3
master/src/main/resources/application.yml

@@ -19,6 +19,10 @@ ruoyi:
   # 验证码类型 math 数组计算 char 字符验证
   captchaType: math
 
+jpush:
+  appKey: 2c1d3d89dc7cfb5ff22e6eb9
+  masterSecret: ca98a81c8339a81b3b85fb6a
+
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
@@ -205,6 +209,4 @@ gen:
 #C:\Users\ly\.m2\repository\org\jasypt\jasypt\1.9.2>java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="ssy123456" password=test algorithm=PBEWithMD5AndDES
 jasypt:
   encryptor:
-    password: test
-
-
+    password: test