2
Google의 Firebase Messaging 플랫폼을 내 앱에 연결하려고합니다.이를 단순화하기 위해 Spring의 RestTemplate REST 추상화를 사용하려고합니다.스프링 부트 RestTemplate.postForObject를 Firebase 메시징으로 반환하지 않습니다.
이RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.add("Authorization", "key=" + Constants.FIREBASE_SERVER_KEY);
headers.add("Content-Type", "application/json");
HttpEntity<FireBasePost> entity = new HttpEntity<>(fbp, headers);
URI uri;
uri = new URI(firebaseApi);
FireBaseResponse fbr = restTemplate.postForObject(uri, entity, FireBaseResponse.class);
FireBasePost 객체 그냥 필요한 POST 메시지 API에 대한 필드 포함 : 나는 현재에 노력하고있어
Firebase API을 - 내가 요청 엔티티를 확인한 때문에, String.class에 게시하여 작동 응답은 비 정렬 JSON입니다.
그러나 FireBaseResponse 객체에 직접 marshall에 대한 응답을 얻으려고 시도하면 postForObject 호출이 중지되어 반환되지 않습니다.
@JsonIgnoreProperties(ignoreUnknown = true)
public class FireBaseResponse {
public Integer multicast_id;
public Integer success;
public Integer failure;
public Integer canonical_ids;
public FireBaseResponse() {}
}
이 호출이 완료되지 않는 이유를 이해하는 데 문제가 있습니다. 나는 객체에 직접 응답 할 수 있기를 원합니다.
내가 FireBaseResponse' 속성 이름은 바로 규칙을 따르지 않는'생각합니다. 낙타의 경우 이름으로 시도하십시오 ('multicastId','canonicalIds' 등). Firebase 응답을 게시 할 수 있습니까? –
클라이언트 측에서받은 알림을 처리 할 수 있습니까? 예를 들어, func 어플리케이션 (_ application : UIApplication, didReceiveRemoteNotification userInfo : [AnyHashable : Any], fetchCompletionHandler completionHandler : @escaping (UIBackgroundFetchResult) ->())'delegate? – Dayna