aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java/com/juick/components/configuration/APNSConfiguration.java
blob: 43ea3943b6e67dbd52e18ebd5da553203548032c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.juick.components.configuration;

import com.turo.pushy.apns.ApnsClient;
import com.turo.pushy.apns.ApnsClientBuilder;
import com.turo.pushy.apns.auth.ApnsSigningKey;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.File;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * Created by vital on 28.03.2017.
 */
@Configuration
public class APNSConfiguration {
    @Value("${ios_p8_key:}")
    private String p8key;
    @Value("${ios_team_id:}")
    private String teamId;
    @Value("${ios_key_id:}")
    private String keyId;
    @Bean
    public ApnsClient apns() throws NoSuchAlgorithmException, InvalidKeyException, IOException {
        return new ApnsClientBuilder()
                .setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
                .setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File(p8key),
                        teamId, keyId))
                .build();
    }
}