当前位置: 首页>>代码示例>>Java>>正文


Java APNS类代码示例

本文整理汇总了Java中com.notnoop.apns.APNS的典型用法代码示例。如果您正苦于以下问题:Java APNS类的具体用法?Java APNS怎么用?Java APNS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


APNS类属于com.notnoop.apns包,在下文中一共展示了APNS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testApns

import com.notnoop.apns.APNS; //导入依赖的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);
	}
}
 
开发者ID:dzh,项目名称:jframe,代码行数:24,代码来源:TestApns.java

示例2: init

import com.notnoop.apns.APNS; //导入依赖的package包/类
@PostConstruct
public void init() {
	boolean production = EnvUtil.getEnv().equals(EnvUtil.ENV_PROD);
	String folder;
	if (production) {
		folder = "apns-prod";
	}
	else {
		folder = "apns-dev";
	}
	InputStream input;
	try {
		input = new ClassPathResource("/" + folder + "/push.p12").getInputStream();
	}
	catch (IOException e) {
		throw new IORuntimeException(e.getMessage(), e);
	}
	if (production) {
		apnsService = APNS.newService().withCert(input, password).withProductionDestination().asBatched().build();
	}
	else {
		apnsService = APNS.newService().withCert(input, password).withSandboxDestination().asBatched().build();
	}
	IOUtils.closeQuietly(input);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:26,代码来源:ApnsClientImpl.java

示例3: pushAll

import com.notnoop.apns.APNS; //导入依赖的package包/类
@Override
@ApiMethod(path = "pushAllToApns")
public void pushAll(@Named("documentId") String docId, @Named("messageType") String messageType,
    @Named("message") String message) {
  // ping a max of 10 registered devices
  Set<String> subscriptions = presence.listDocumentSubscriptions(docId, Platform.IOS.name());
  if (subscriptions == null || subscriptions.isEmpty()) {
    return;
  }
  PayloadBuilder payloadBuilder = APNS.newPayload().customField(messageType, message);
  log.info("payload length:" + payloadBuilder.length());
  String payload = payloadBuilder.build();
  for (String subscription : subscriptions) {
    String id = subscription;
    String token = util.get().channelTokenFor(id);
    if (token == null) {
      continue;
    }
    apnsService.get().push(token, payload);
  }
  // Map<String, Date> inactiveDevices = service.getInactiveDevices();
  // inactiveDevices.toString();
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:24,代码来源:ApplePushNotification.java

示例4: provideApnsService

import com.notnoop.apns.APNS; //导入依赖的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();
}
 
开发者ID:larrytin,项目名称:realtime-server-appengine,代码行数:20,代码来源:RealtimeServletModule.java

示例5: main

import com.notnoop.apns.APNS; //导入依赖的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...");
}
 
开发者ID:aggarwalankush,项目名称:push-notification-server,代码行数:16,代码来源:IOSPush.java

示例6: send

import com.notnoop.apns.APNS; //导入依赖的package包/类
@Override
public boolean send(String deviceToken, int badge, String body) {
	String payload = APNS.newPayload().alertBody(body).badge(badge).build();
	apnsService.push(deviceToken, payload);
	return true;

}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:8,代码来源:ApnsClientImpl.java

示例7: testProducerWithoutTokenHeader

import com.notnoop.apns.APNS; //导入依赖的package包/类
@Test(timeout = 5000)
public void testProducerWithoutTokenHeader() throws Exception {
    String message = "Hello World";
    String messagePayload = APNS.newPayload().alertBody(message).build();

    EnhancedApnsNotification apnsNotification = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
    server.stopAt(apnsNotification.length());

    template.sendBody("direct:test", message);

    server.getMessages().acquire();
    assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:ApnsProducerWithoutTokensHeaderTest.java

示例8: testProducer

import com.notnoop.apns.APNS; //导入依赖的package包/类
@Test(timeout = 5000)
public void testProducer() throws Exception {
    String message = "Hello World";
    String messagePayload = APNS.newPayload().alertBody(message).build();

    EnhancedApnsNotification apnsNotification = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
    server.stopAt(apnsNotification.length());

    template.sendBody("direct:test", message);

    server.getMessages().acquire();
    assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:ApnsProducerTest.java

示例9: testProducerWithApnsNotification

import com.notnoop.apns.APNS; //导入依赖的package包/类
@Test(timeout = 5000)
public void testProducerWithApnsNotification() throws InterruptedException {
    String message = "Hello World";
    String messagePayload = APNS.newPayload().alertBody(message).build();

    final EnhancedApnsNotification apnsNotification =
            new EnhancedApnsNotification(14, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
    server.stopAt(apnsNotification.length());

    template.sendBody("direct:testWithApnsNotification", apnsNotification);

    server.getMessages().acquire();
    assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray());

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:ApnsProducerTest.java

示例10: MMXPushAPNSPayloadBuilder

import com.notnoop.apns.APNS; //导入依赖的package包/类
public MMXPushAPNSPayloadBuilder(PushMessage.Action action) {
  builder = APNS.newPayload();
  mmxDictionary = new HashMap<String, Object>(10);
  if (action == PushMessage.Action.WAKEUP) {
    builder.instantDeliveryOrSilentNotification();
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:8,代码来源:MMXPushAPNSPayloadBuilder.java

示例11: MailMessageManager

import com.notnoop.apns.APNS; //导入依赖的package包/类
MailMessageManager() {
	try {
		//Setup APNS connection
		boolean isDevelopment = GlobalConfig.getInstance().getBooleanProperty(
				GlobalConfigKey.ios_push_develop);
		String certificatePath = GlobalConfig.getInstance().getStringProperty(
				GlobalConfigKey.ios_push_production_pem);
		String password = GlobalConfig.getInstance().getStringProperty(
				GlobalConfigKey.ios_push_certificate_password);
		if ( isDevelopment ) {
			certificatePath = GlobalConfig.getInstance().getStringProperty(GlobalConfigKey.ios_push_development_pem);
			iosApnService = APNS.newService()
			    .withCert(certificatePath, password)
			    .withSandboxDestination()
			    .build();
		} else {
			iosApnService = APNS.newService()
			    .withCert(certificatePath, password)
			    .withProductionDestination()
			    .build();
		}
		logger.debug("APNS use certificate: {}", certificatePath);
	} catch (Exception e) {
		iosApnService = null;
		logger.warn("Failed to setup APN service");
	}
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:28,代码来源:MailMessageManager.java

示例12: sendOneSimple

import com.notnoop.apns.APNS; //导入依赖的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());
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:13,代码来源:ApnsConnectionTest.java

示例13: sendOneQueued

import com.notnoop.apns.APNS; //导入依赖的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());
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:14,代码来源:ApnsConnectionTest.java

示例14: simpleFeedback

import com.notnoop.apns.APNS; //导入依赖的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());
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:13,代码来源:FeedbackTest.java

示例15: threeFeedback

import com.notnoop.apns.APNS; //导入依赖的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());
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:13,代码来源:FeedbackTest.java


注:本文中的com.notnoop.apns.APNS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。