diff --git a/src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java b/src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java index 2bff666..3b0f320 100644 --- a/src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java +++ b/src/main/java/cn/wildfirechat/push/android/fcm/FCMPush.java @@ -25,12 +25,18 @@ public class FCMPush { @PostConstruct private void init() throws Exception { + try { + FileInputStream refreshToken = new FileInputStream(mConfig.getCredentialsPath()); FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(refreshToken)) .setDatabaseUrl("https://.firebaseio.com/") .build(); FirebaseApp.initializeApp(options); + } catch (Exception e) { + LOG.error("FCMPush init failed"); + e.printStackTrace(); + } } diff --git a/src/main/java/cn/wildfirechat/push/android/getui/GetuiPush.java b/src/main/java/cn/wildfirechat/push/android/getui/GetuiPush.java index 39bbb7b..68e5dfb 100644 --- a/src/main/java/cn/wildfirechat/push/android/getui/GetuiPush.java +++ b/src/main/java/cn/wildfirechat/push/android/getui/GetuiPush.java @@ -48,21 +48,26 @@ public class GetuiPush { @PostConstruct public void init() { - // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200 - System.setProperty("http.maxConnections", "200"); - GtApiConfiguration apiConfiguration = new GtApiConfiguration(); - //填写应用配置 - if(!StringUtils.isEmpty(mConfig.getAppId())) { - apiConfiguration.setAppId(mConfig.getAppId()); - apiConfiguration.setAppKey(mConfig.getAppKey()); - apiConfiguration.setMasterSecret(mConfig.getMasterSecret()); - // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId - apiConfiguration.setDomain("https://restapi.getui.com/v2/"); -// apiConfiguration.setDomain(mConfig.getDomain()); - // 实例化ApiHelper对象,用于创建接口对象 - ApiHelper apiHelper = ApiHelper.build(apiConfiguration); - // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi - this.pushApi = apiHelper.creatApi(PushApi.class); + try{ + // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200 + System.setProperty("http.maxConnections", "200"); + GtApiConfiguration apiConfiguration = new GtApiConfiguration(); + //填写应用配置 + if(!StringUtils.isEmpty(mConfig.getAppId())) { + apiConfiguration.setAppId(mConfig.getAppId()); + apiConfiguration.setAppKey(mConfig.getAppKey()); + apiConfiguration.setMasterSecret(mConfig.getMasterSecret()); + // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId + apiConfiguration.setDomain("https://restapi.getui.com/v2/"); + // apiConfiguration.setDomain(mConfig.getDomain()); + // 实例化ApiHelper对象,用于创建接口对象 + ApiHelper apiHelper = ApiHelper.build(apiConfiguration); + // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi + this.pushApi = apiHelper.creatApi(PushApi.class); + } + } catch (Exception e) { + LOG.error("GetuiPush init failed"); + e.printStackTrace(); } } diff --git a/src/main/java/cn/wildfirechat/push/android/meizu/MeiZuPush.java b/src/main/java/cn/wildfirechat/push/android/meizu/MeiZuPush.java index 00a8f9f..a48afca 100644 --- a/src/main/java/cn/wildfirechat/push/android/meizu/MeiZuPush.java +++ b/src/main/java/cn/wildfirechat/push/android/meizu/MeiZuPush.java @@ -25,7 +25,13 @@ public class MeiZuPush { @PostConstruct 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 diff --git a/src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java b/src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java index fd71475..51b233f 100644 --- a/src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java +++ b/src/main/java/cn/wildfirechat/push/android/oppo/OppoPush.java @@ -30,6 +30,7 @@ public class OppoPush { try { mSender = new Sender(mConfig.getAppKey(), mConfig.getAppSecret()); } catch (Exception e) { + LOG.error("OppoPush init failed"); e.printStackTrace(); } } diff --git a/src/main/java/cn/wildfirechat/push/ios/ApnsServer.java b/src/main/java/cn/wildfirechat/push/ios/ApnsServer.java index 5f359b9..a8da3ef 100644 --- a/src/main/java/cn/wildfirechat/push/ios/ApnsServer.java +++ b/src/main/java/cn/wildfirechat/push/ios/ApnsServer.java @@ -21,13 +21,8 @@ import org.springframework.util.StringUtils; import javax.annotation.PostConstruct; import java.io.File; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; import java.util.Calendar; -import static java.lang.System.exit; - @Component public class ApnsServer { private static final Logger LOG = LoggerFactory.getLogger(ApnsServer.class); @@ -110,13 +105,9 @@ public class ApnsServer { .build(); } } - } catch (IOException e) { + } catch (Exception e) { + LOG.error("ApnsServer init failed"); e.printStackTrace(); - exit(-1); - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } catch (InvalidKeyException e) { - throw new RuntimeException(e); } }