Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9432969cb4 |
@@ -19,6 +19,8 @@ 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();
|
||||||
}
|
}
|
||||||
@@ -39,8 +41,10 @@ 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) {
|
||||||
throw new RuntimeException("Failed to initialize Firebase", e);
|
this.isInitialized = false;
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,6 +98,12 @@ 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,6 +17,7 @@ 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();
|
||||||
@@ -38,13 +39,21 @@ 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) {
|
||||||
throw new RuntimeException("Failed to init VoIP APNs client", e);
|
this.isInitialized = false;
|
||||||
|
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