Java APNS使用FCM令牌从Java推送到iOS应用程序?

时间:2017-12-26 09:53:16

标签: java ios swift swift3

我想从java web应用程序向iOS应用程序发送推送通知。它显示错误..我使用波纹管代码从java服务器发送通知到iOS应用程序。

import com.notnoop.apns.*;
public class PushNotifications {

   public static void main(String[] args) {
      PushNotifications pushNotifications = new PushNotifications();
      pushNotifications.sendNotificaton();
    } 

void sendNotificaton() {

    ApnsService service
            = APNS.newService()
                    .withCert(this.getClass().getClassLoader().getResourceAsStream("Certificates.p12"), "123456")
                    .withSandboxDestination() 
                    .build();

    String payload
            = APNS.newPayload()
                    .alertBody("My Message")
                    .badge(1)
                    .sound("default")
                    .build();

  //Token
    String deviceToken = "BD00825B7FDA300705C2EFDE0821B94815F9D76CCFE54BF36CF23E8EAAC949EC";

    //log.warn("Sending push notification...");
    service.push(deviceToken, payload);
  } 

}

注意:我的Certificates.p12粘贴到netbeans默认源包目录。 我的错误显示..

Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.jackson.type.JavaType.isMapLikeType()Z
at org.codehaus.jackson.map.ser.BasicSerializerFactory.buildContainerSerializer(BasicSerializerFactory.java:416)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:268)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:782)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:735)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:344)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findTypedValueSerializer(StdSerializerProvider.java:420)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:601)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:2575)
at org.codehaus.jackson.map.ObjectMapper.writeValueAsString(ObjectMapper.java:2097)
at com.notnoop.apns.PayloadBuilder.build(PayloadBuilder.java:365)
at fcm.PushNotifications.sendNotificaton(PushNotifications.java:34)
at fcm.PushNotifications.main(PushNotifications.java:17)
/Users/Enamul/Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53:     Java returned: 1
BUILD FAILED (total time: 1 second)

提前谢谢......请帮助我..

0 个答案:

没有答案