fix app推送证书位置

master
luoyang 6 years ago
parent 2dbd4e9443
commit e59883442c

@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@ -21,14 +23,14 @@ public class APNSMessageHelper {
@Value("classpath:apple_message_cert_dev.p12")
private org.springframework.core.io.Resource appleMessageFileDev;
@Value("classpath:apple_message_cert_product.p12")
private org.springframework.core.io.Resource appleMessageFileProduct;
@Value("${apple.message.apns.file}")
private String appleApnsFile;
@Value("${apple.message.apns.password}")
private String appleMessagePassword;
public void sendAppleMessage(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
/**设置参数,发送数据**/
InputStream keyIns = appleMessageFileProduct.getInputStream();
InputStream keyIns = new FileInputStream(new File(appleApnsFile));
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
String payload = APNS.newPayload().alertTitle(title).alertBody(body).badge(1).sound("default").customField("data", data).customField("type", type).build();
service.push(token, payload);
@ -37,7 +39,7 @@ public class APNSMessageHelper {
public void sendAppleMessageDetail(String title, String body, String token, JSONObject data, JSONObject type) throws IOException {
/**设置参数,发送数据**/
InputStream keyIns = appleMessageFileProduct.getInputStream();
InputStream keyIns = new FileInputStream(new File(appleApnsFile));
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword).withProductionDestination().build();
String payload = APNS.newPayload().alertTitle(title).alertBody(body).category("myNotificationCategory").badge(1).sound("default").customField("data", data).customField("type", type).build();
service.push(token, payload);

Loading…
Cancel
Save