当某种推送未正确配置,不能正常初始化时,打印日志,但不退出

This commit is contained in:
imndx
2025-01-16 16:18:53 +08:00
parent 6cc3c15bb7
commit 4b63d34cf7
5 changed files with 36 additions and 27 deletions

View File

@@ -25,12 +25,18 @@ public class FCMPush {
@PostConstruct @PostConstruct
private void init() throws Exception { private void init() throws Exception {
try {
FileInputStream refreshToken = new FileInputStream(mConfig.getCredentialsPath()); FileInputStream refreshToken = new FileInputStream(mConfig.getCredentialsPath());
FirebaseOptions options = FirebaseOptions.builder() FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(refreshToken)) .setCredentials(GoogleCredentials.fromStream(refreshToken))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/") .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build(); .build();
FirebaseApp.initializeApp(options); FirebaseApp.initializeApp(options);
} catch (Exception e) {
LOG.error("FCMPush init failed");
e.printStackTrace();
}
} }

View File

@@ -48,21 +48,26 @@ public class GetuiPush {
@PostConstruct @PostConstruct
public void init() { public void init() {
// 设置httpClient最大连接数当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200 try{
System.setProperty("http.maxConnections", "200"); // 设置httpClient最大连接数当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200
GtApiConfiguration apiConfiguration = new GtApiConfiguration(); System.setProperty("http.maxConnections", "200");
//填写应用配置 GtApiConfiguration apiConfiguration = new GtApiConfiguration();
if(!StringUtils.isEmpty(mConfig.getAppId())) { //填写应用配置
apiConfiguration.setAppId(mConfig.getAppId()); if(!StringUtils.isEmpty(mConfig.getAppId())) {
apiConfiguration.setAppKey(mConfig.getAppKey()); apiConfiguration.setAppId(mConfig.getAppId());
apiConfiguration.setMasterSecret(mConfig.getMasterSecret()); apiConfiguration.setAppKey(mConfig.getAppKey());
// 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId apiConfiguration.setMasterSecret(mConfig.getMasterSecret());
apiConfiguration.setDomain("https://restapi.getui.com/v2/"); // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
// apiConfiguration.setDomain(mConfig.getDomain()); apiConfiguration.setDomain("https://restapi.getui.com/v2/");
// 实例化ApiHelper对象用于创建接口对象 // apiConfiguration.setDomain(mConfig.getDomain());
ApiHelper apiHelper = ApiHelper.build(apiConfiguration); // 实例化ApiHelper对象用于创建接口对象
// 创建对象建议复用。目前有PushApi、StatisticApi、UserApi ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
this.pushApi = apiHelper.creatApi(PushApi.class); // 创建对象建议复用。目前有PushApi、StatisticApi、UserApi
this.pushApi = apiHelper.creatApi(PushApi.class);
}
} catch (Exception e) {
LOG.error("GetuiPush init failed");
e.printStackTrace();
} }
} }

View File

@@ -25,7 +25,13 @@ public class MeiZuPush {
@PostConstruct @PostConstruct
public void init() { public void init() {
this.flymePush = new IFlymePush(mConfig.getAppSecret()); try {
//初始化推送sdk
this.flymePush = new IFlymePush(mConfig.getAppSecret());
} catch (Exception e) {
LOG.error("MeiZuPush init failed");
e.printStackTrace();
}
} }
@Autowired @Autowired

View File

@@ -30,6 +30,7 @@ public class OppoPush {
try { try {
mSender = new Sender(mConfig.getAppKey(), mConfig.getAppSecret()); mSender = new Sender(mConfig.getAppKey(), mConfig.getAppSecret());
} catch (Exception e) { } catch (Exception e) {
LOG.error("OppoPush init failed");
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@@ -21,13 +21,8 @@ import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Calendar; import java.util.Calendar;
import static java.lang.System.exit;
@Component @Component
public class ApnsServer { public class ApnsServer {
private static final Logger LOG = LoggerFactory.getLogger(ApnsServer.class); private static final Logger LOG = LoggerFactory.getLogger(ApnsServer.class);
@@ -110,13 +105,9 @@ public class ApnsServer {
.build(); .build();
} }
} }
} catch (IOException e) { } catch (Exception e) {
LOG.error("ApnsServer init failed");
e.printStackTrace(); e.printStackTrace();
exit(-1);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (InvalidKeyException e) {
throw new RuntimeException(e);
} }
} }