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

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,6 +48,7 @@ public class GetuiPush {
@PostConstruct @PostConstruct
public void init() { public void init() {
try{
// 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200 // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200
System.setProperty("http.maxConnections", "200"); System.setProperty("http.maxConnections", "200");
GtApiConfiguration apiConfiguration = new GtApiConfiguration(); GtApiConfiguration apiConfiguration = new GtApiConfiguration();
@@ -58,12 +59,16 @@ public class GetuiPush {
apiConfiguration.setMasterSecret(mConfig.getMasterSecret()); apiConfiguration.setMasterSecret(mConfig.getMasterSecret());
// 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
apiConfiguration.setDomain("https://restapi.getui.com/v2/"); apiConfiguration.setDomain("https://restapi.getui.com/v2/");
// apiConfiguration.setDomain(mConfig.getDomain()); // apiConfiguration.setDomain(mConfig.getDomain());
// 实例化ApiHelper对象,用于创建接口对象 // 实例化ApiHelper对象,用于创建接口对象
ApiHelper apiHelper = ApiHelper.build(apiConfiguration); ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
// 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
this.pushApi = apiHelper.creatApi(PushApi.class); this.pushApi = apiHelper.creatApi(PushApi.class);
} }
} catch (Exception e) {
LOG.error("GetuiPush init failed");
e.printStackTrace();
}
} }
public void push(PushMessage pushMessage, boolean isAndroid) { public void push(PushMessage pushMessage, boolean isAndroid) {

View File

@@ -25,7 +25,13 @@ public class MeiZuPush {
@PostConstruct @PostConstruct
public void init() { public void init() {
try {
//初始化推送sdk
this.flymePush = new IFlymePush(mConfig.getAppSecret()); 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);
} }
} }