• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java APNS类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: simpleQueuedFeedback

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


示例17: threeQueuedFeedback

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


示例18: main

import com.notnoop.apns.APNS; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Configuration config = buildConfiguration(args);
    //
    // Database
    //
    WebPushStoreConfiguration pushStoreConfiguration = new WebPushStoreConfiguration(config);
    SQLiteWebPushStore sqLiteWebPushStore = SQLiteWebPushStoreFactory.create(pushStoreConfiguration);
    //
    // PackageZip
    //
    PackageZipConfiguration packageZipConfiguration = new PackageZipConfiguration(config);
    PackageZipSigner packageSigner = new PackageZipSigner(packageZipConfiguration);
    PackageZipBuilder packageZipBuilder = new PackageZipBuilder(packageZipConfiguration, packageSigner);
    PackageZipPool packageZipPool = new PackageZipPool(packageZipConfiguration);
    PackageZipPoolPopulate packageZipPoolPopulate = new PackageZipPoolPopulate(packageZipPool, packageZipBuilder);
    //
    // Apns Push Service
    //
    ApnsConfiguration apnsConfiguration = new ApnsConfiguration(config);
    ApnsService apnsService = APNS.newService().withCert(apnsConfiguration.apnsCertLocation, apnsConfiguration.apnsCertPassword).withProductionDestination().build();
    ApnsPushManager apnsPushManager = new ApnsPushManager(apnsService, apnsConfiguration, sqLiteWebPushStore);
    ApnsFeedbackService apnsFeedbackService = new ApnsFeedbackService(apnsService, apnsConfiguration, sqLiteWebPushStore);
    //
    // Jetty
    //
    HttpConfiguration httpConfiguration = new HttpConfiguration(config);
    WebPushUserIdAuth webPushUserIdAuth = new WebPushUserIdAuth(sqLiteWebPushStore, httpConfiguration);
    Server jettyServer = HttpServiceFactory.create(sqLiteWebPushStore, webPushUserIdAuth, packageZipPool, apnsPushManager, httpConfiguration);
    // START
    apnsService.start();
    apnsFeedbackService.startAndWait();
    Executors.newSingleThreadExecutor().submit(packageZipPoolPopulate);
    jettyServer.start();
}
 
开发者ID:chriskearney,项目名称:stickypunch,代码行数:35,代码来源:Main.java


示例19: sendApnsNotification

import com.notnoop.apns.APNS; //导入依赖的package包/类
public void sendApnsNotification() {
	 String registrationId = "ab4fa0c794688dca7c149cbac1001ed2f451d02e4c55cc25be45e7693ad3aae3";
	 String message = "Hello";
	 ApnsServiceBuilder sb = APNS.newService();
	 
	 sb.withCert("/tmp/apns-dev.p12", "Enterprisy").withSandboxDestination();
	 
	 PayloadBuilder pb = APNS.newPayload();
	 pb.alertBody(message);
	 pb.sound("default");
	 pb.badge(1);
	 		 
	 sb.build().push(new EnhancedApnsNotification(1, 900, registrationId, pb.build()));
}
 
开发者ID:MinHalsoplan,项目名称:netcare-healthplan,代码行数:15,代码来源:OtherTests.java


示例20: testConnection

import com.notnoop.apns.APNS; //导入依赖的package包/类
/**
 * Test the connection with APNS server.
 * 
 * @param certPath the certificate path.
 * @param pass the password.
 * @param useSandbox if use Sandbox.
 */
private void testConnection(String certPath, String pass, boolean useSandbox) {
  try {
    final InputStream fileInputStream =
        KettleVFS.getInputStream(transMeta.environmentSubstitute(certPath));

    ApnsServiceBuilder apnsServiceBuilder = APNS.newService().withCert(fileInputStream,
        transMeta.environmentSubstitute(pass));
    if (useSandbox) {
      apnsServiceBuilder = apnsServiceBuilder.withSandboxDestination();
    } else {
      apnsServiceBuilder = apnsServiceBuilder.withProductionDestination();
    }
    final ApnsService apnsService = apnsServiceBuilder.build();
    apnsService.testConnection();
    final ShowMessageDialog msgDialog =
        new ShowMessageDialog(parent, SWT.ICON_INFORMATION | SWT.OK,
            BaseMessages.getString(PKG, "ApplePushNotification.TestConnection.title"),
            BaseMessages.getString(
                PKG, "ApplePushNotification.TestConnection.Success.DialogMessage"));
    msgDialog.open();
  } catch (Exception e) {
    logDebug(BaseMessages.getString(PKG, "ApplePushNotification.TestConnection.title"), e);
    new ErrorDialog(shell, BaseMessages.getString(PKG,
        "ApplePushNotification.TestConnection.title"),
        BaseMessages.getString(PKG,
            "ApplePushNotification.Exception.UnexpectedErrorInTestConnection.Dialog.Error"), e);
  }
}
 
开发者ID:latinojoel,项目名称:pdi-apple-pushnotifications,代码行数:36,代码来源:PushNotificationDialog.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TransactionResult类代码示例发布时间:2022-05-22
下一篇:
Java WorldGenGlowStone1类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap