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