commit
c752d2c33f
Binary file not shown.
@ -0,0 +1,46 @@
|
||||
package au.com.royalpay.payment.manage.valid;
|
||||
|
||||
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
||||
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.notnoop.apns.APNS;
|
||||
import com.notnoop.apns.ApnsService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Create by davep at 2020-01-06 16:04
|
||||
*/
|
||||
public class APNSTest {
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String appleMessagePassword = "BSNMNkxPq0AT";
|
||||
AppMessage msg = new AppMessage("MESSAGE","test","test content");
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("send_type","rloan_creditFinished");
|
||||
msg.setData(data);
|
||||
JSONObject typeData = new JSONObject();
|
||||
typeData.put("send_type","MESSAGE");
|
||||
typeData.put("id", UUID.randomUUID().toString());
|
||||
msg.setTypeData(typeData);
|
||||
URL cert = getClass().getClassLoader().getResource("rloan_dev_apns.p12");
|
||||
try(InputStream keyIns = cert.openStream()) {
|
||||
ApnsService service = APNS.newService().withCert(keyIns, appleMessagePassword)
|
||||
.withSandboxDestination().build();
|
||||
String payload = APNS.newPayload().alertTitle("test").alertBody("test")
|
||||
.badge(1).sound("default").customField("data", msg.getData()).customField("type", msg.getTypeData()).build();
|
||||
JSONObject p = JSON.parseObject(payload);
|
||||
JSONObject aps = p.getJSONObject("aps");
|
||||
aps.put("mutable-content", "1");
|
||||
service.push("486A623E9A5AC2EB28DFBF3C827979293E9E9F9E1252603E7E1F8C878695FA57", p.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in new issue