Compare commits
2 Commits
58fe3c409d
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 9432969cb4 | |||
|
|
f87198c054 |
@@ -9,7 +9,8 @@ public enum AttachmentType {
|
||||
FILE(2),
|
||||
AVATAR(3),
|
||||
CALL(4),
|
||||
VOICE(5);
|
||||
VOICE(5),
|
||||
VIDEO_CIRCLE(6);
|
||||
|
||||
|
||||
private final int code;
|
||||
|
||||
@@ -19,6 +19,8 @@ import im.rosetta.service.dispatch.runtime.PushType;
|
||||
|
||||
public class FCM extends Pusher {
|
||||
|
||||
private boolean isInitialized = false;
|
||||
|
||||
public FCM() {
|
||||
initializeFirebase();
|
||||
}
|
||||
@@ -39,8 +41,10 @@ public class FCM extends Pusher {
|
||||
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
|
||||
.build();
|
||||
FirebaseApp.initializeApp(options);
|
||||
this.isInitialized = true;
|
||||
} 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
|
||||
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,6 +17,7 @@ public class VoIPApns extends Pusher {
|
||||
|
||||
private ApnsClient client;
|
||||
private String topic;
|
||||
private boolean isInitialized = false;
|
||||
|
||||
public VoIPApns(){
|
||||
this.initializeApns();
|
||||
@@ -38,13 +39,21 @@ public class VoIPApns extends Pusher {
|
||||
.setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
|
||||
.setClientCredentials(new File(p12Path), p12Password)
|
||||
.build();
|
||||
this.isInitialized = true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to init VoIP APNs client", e);
|
||||
this.isInitialized = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@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