本文整理汇总了Java中com.notnoop.apns.ApnsService类的典型用法代码示例。如果您正苦于以下问题:Java ApnsService类的具体用法?Java ApnsService怎么用?Java ApnsService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApnsService类属于com.notnoop.apns包,在下文中一共展示了ApnsService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testApns
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void testApns() {
ApnsService service = APNS.newService()
.withCert("/Users/dzh/temp/lech/drivercer.p12", "123456")
.withSandboxDestination().build();
String payload = APNS.newPayload()
// .alertTitle("爱拼车22")
.customField("custom1", "custom1")
.alertBody("Can't be simpler than this!").build();
System.out.println(payload);
String token = "70854405ac6b60b64bdc5338a2d8f4a55a683f63e786a872be42454f6731618d";
token = "644737130b7d6dde50c1cf1e6fe6bb8be81f728d4b51fc357e3706e431bea213";
// String token = "83c02996f76268c6b569943cd42feec6"
service.push(token, payload);
service.testConnection();
Map<String, Date> inactiveDevices = service.getInactiveDevices();
for (String deviceToken : inactiveDevices.keySet()) {
Date inactiveAsOf = inactiveDevices.get(deviceToken);
System.out.println(deviceToken);
System.out.println(inactiveAsOf);
}
}
示例2: provideApnsService
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Provides
@Singleton
ApnsService provideApnsService(ServletContext context,
@Flag(FlagName.APNS_CERT_PASSWORD) String password) {
String ksAlgorithm =
((KeyManagerFactory.getDefaultAlgorithm() == null) ? "sunx509" : KeyManagerFactory
.getDefaultAlgorithm());
InputStream inputStream;
if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
// The app is running on App Engine...
// inputStream = context.getResourceAsStream("/WEB-INF/ApnsProduction.jks");
inputStream = context.getResourceAsStream("/WEB-INF/ApnsDevelopment.jks");
} else {
inputStream = context.getResourceAsStream("/WEB-INF/ApnsDevelopment.jks");
}
SSLContext sslContext = Utilities.newSSLContext(inputStream, password, "JKS", ksAlgorithm);
return APNS.newService().withSSLContext(sslContext).withSandboxDestination()
.withNoErrorDetection().build();
}
示例3: main
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
public static void main(String[] args) {
ApnsService service =
APNS.newService()
.withCert(PATH_TO_P12_CERT, CERT_PASSWORD)
.withSandboxDestination()
.build();
String payload = APNS.newPayload()
.alertBody("My first notification\nHello, I'm push notification")
.sound("default")
.build();
service.push(DEVICE_TOKEN, payload);
System.out.println("The message has been hopefully sent...");
}
示例4: createCamelContext
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
ApnsService apnsService = apnsServiceFactory.getApnsService();
ApnsComponent apnsComponent = new ApnsComponent(apnsService);
camelContext.addComponent("apns", apnsComponent);
return camelContext;
}
示例5: testApnsServiceFactoryWithFixedCertificates
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void testApnsServiceFactoryWithFixedCertificates() throws Exception {
ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificates();
ApnsService apnsService = apnsServiceFactory.getApnsService();
doBasicAsserts(apnsService);
}
示例6: testApnsServiceFactoryAsPool0
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testApnsServiceFactoryAsPool0() throws Exception {
ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificatesAsPool(0);
ApnsService apnsService = apnsServiceFactory.getApnsService();
doBasicAsserts(apnsService);
}
示例7: testApnsServiceFactoryAsPool1
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void testApnsServiceFactoryAsPool1() throws Exception {
ApnsServiceFactory apnsServiceFactory = createApnsServiceFactoryWithFixedCertificatesAsPool(1);
ApnsService apnsService = apnsServiceFactory.getApnsService();
doBasicAsserts(apnsService);
}
示例8: createCamelContext
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ApnsServiceFactory apnsServiceFactory = ApnsUtils.createDefaultTestConfiguration(camelContext);
ApnsService apnsService = apnsServiceFactory.getApnsService();
ApnsComponent apnsComponent = new ApnsComponent(apnsService);
camelContext.addComponent("apns", apnsComponent);
return camelContext;
}
示例9: sendOneSimple
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test(timeout = 2000)
public void sendOneSimple() throws InterruptedException {
ApnsService service =
APNS.newService().withSSLContext(clientContext())
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.build();
server.stopAt(msg1.length());
service.push(msg1);
server.messages.acquire();
assertArrayEquals(msg1.marshall(), server.received.toByteArray());
}
示例10: sendOneQueued
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test(timeout = 2000)
public void sendOneQueued() throws InterruptedException {
ApnsService service =
APNS.newService().withSSLContext(clientContext())
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.asQueued()
.build();
server.stopAt(msg1.length());
service.push(msg1);
server.messages.acquire();
assertArrayEquals(msg1.marshall(), server.received.toByteArray());
}
示例11: simpleFeedback
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void simpleFeedback() throws IOException {
server.toSend.write(simple);
ApnsService service =
APNS.newService().withSSLContext(clientContext)
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.withFeedbackDestination(TEST_HOST, TEST_FEEDBACK_PORT)
.build();
checkParsedSimple(service.getInactiveDevices());
}
示例12: threeFeedback
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void threeFeedback() throws IOException {
server.toSend.write(three);
ApnsService service =
APNS.newService().withSSLContext(clientContext)
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.withFeedbackDestination(TEST_HOST, TEST_FEEDBACK_PORT)
.build();
checkParsedThree(service.getInactiveDevices());
}
示例13: simpleQueuedFeedback
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void simpleQueuedFeedback() throws IOException {
server.toSend.write(simple);
ApnsService service =
APNS.newService().withSSLContext(clientContext)
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.withFeedbackDestination(TEST_HOST, TEST_FEEDBACK_PORT)
.asQueued()
.build();
checkParsedSimple(service.getInactiveDevices());
}
示例14: threeQueuedFeedback
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void threeQueuedFeedback() throws IOException {
server.toSend.write(three);
ApnsService service =
APNS.newService().withSSLContext(clientContext)
.withGatewayDestination(TEST_HOST, TEST_GATEWAY_PORT)
.withFeedbackDestination(TEST_HOST, TEST_FEEDBACK_PORT)
.asQueued()
.build();
checkParsedThree(service.getInactiveDevices());
}
示例15: pushEvantually
import com.notnoop.apns.ApnsService; //导入依赖的package包/类
@Test
public void pushEvantually() {
ApnsConnection connection = mock(ApnsConnection.class);
ApnsService service = newService(connection, null);
service.push(notification);
verify(connection, times(1)).sendMessage(notification);
}