Skip to content

Commit bbd928f

Browse files
authored
Merge pull request #185 from SEMOSAN/fix/#184-fcm-apns-production
[Fix] TestFlight iOS 백그라운드 푸시 미수신 버그 수정
2 parents c992bc7 + c018587 commit bbd928f

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/semosan/api/common/fcm/FcmService.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.firebase.messaging.Message;
88
import com.google.firebase.messaging.Notification;
99
import lombok.extern.slf4j.Slf4j;
10+
import org.springframework.beans.factory.annotation.Value;
1011
import org.springframework.stereotype.Service;
1112

1213
import java.util.Map;
@@ -15,6 +16,9 @@
1516
@Service
1617
public class FcmService {
1718

19+
@Value("${fcm.apns-environment:production}")
20+
private String apnsEnvironment;
21+
1822
public String sendMessage(
1923
String token,
2024
String title,
@@ -33,9 +37,7 @@ public String sendMessage(
3337
builder.setNotification(notification);
3438
}
3539

36-
if (dataOnly) {
37-
builder.setApnsConfig(silentPushApnsConfig());
38-
}
40+
builder.setApnsConfig(dataOnly ? silentPushApnsConfig() : normalPushApnsConfig());
3941

4042
if (data != null && !data.isEmpty()) {
4143
builder.putAllData(data);
@@ -46,8 +48,15 @@ public String sendMessage(
4648
return response;
4749
}
4850

51+
private ApnsConfig normalPushApnsConfig() {
52+
return ApnsConfig.builder()
53+
.putHeader("apns-environment", apnsEnvironment)
54+
.build();
55+
}
56+
4957
private ApnsConfig silentPushApnsConfig() {
5058
return ApnsConfig.builder()
59+
.putHeader("apns-environment", apnsEnvironment)
5160
.setAps(Aps.builder()
5261
.setContentAvailable(true)
5362
.build())

src/main/resources/application.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ test:
4646
firebase:
4747
service-account-path: ${FIREBASE_SERVICE_ACCOUNT_PATH}
4848

49+
fcm:
50+
apns-environment: ${FCM_APNS_ENVIRONMENT:production}
51+
4952
springdoc:
5053
swagger-ui:
5154
path: /swagger-ui.html

0 commit comments

Comments
 (0)