Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4125846ec |
@@ -19,8 +19,6 @@ import im.rosetta.service.dispatch.runtime.PushType;
|
||||
|
||||
public class FCM extends Pusher {
|
||||
|
||||
private boolean isInitialized = false;
|
||||
|
||||
public FCM() {
|
||||
initializeFirebase();
|
||||
}
|
||||
@@ -41,10 +39,8 @@ public class FCM extends Pusher {
|
||||
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
|
||||
.build();
|
||||
FirebaseApp.initializeApp(options);
|
||||
this.isInitialized = true;
|
||||
} catch (IOException e) {
|
||||
this.isInitialized = false;
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to initialize Firebase", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,12 +94,6 @@ public class FCM extends Pusher {
|
||||
|
||||
@Override
|
||||
public void sendPush(String token, HashMap<String, String> data) {
|
||||
if(!this.isInitialized){
|
||||
/**
|
||||
* Firebase не инициализирован, пропускаем отправку уведомлений
|
||||
*/
|
||||
return;
|
||||
}
|
||||
try{
|
||||
Message message = this.buildMessage(token, data);
|
||||
FirebaseMessaging.getInstance().send(message);
|
||||
|
||||
@@ -17,7 +17,6 @@ public class VoIPApns extends Pusher {
|
||||
|
||||
private ApnsClient client;
|
||||
private String topic;
|
||||
private boolean isInitialized = false;
|
||||
|
||||
public VoIPApns(){
|
||||
this.initializeApns();
|
||||
@@ -39,21 +38,13 @@ public class VoIPApns extends Pusher {
|
||||
.setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
|
||||
.setClientCredentials(new File(p12Path), p12Password)
|
||||
.build();
|
||||
this.isInitialized = true;
|
||||
} catch (Exception e) {
|
||||
this.isInitialized = false;
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to init VoIP APNs client", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPush(String token, HashMap<String, String> data) {
|
||||
if(!this.isInitialized) {
|
||||
/**
|
||||
* Нет файла для инициализации APNs клиента, пропускаем отправку VoIP уведомлений
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if(data.get("type") != PushType.CALL) {
|
||||
/**
|
||||
* Для VoIP APNs отправляем уведомления только о входящих звонках
|
||||
|
||||
Reference in New Issue
Block a user