Javapn给InvalidDeviceTokenFormatE

Javapn给InvalidDeviceTokenFormatE

我正在使用Java PNS发送通知。但是,我收到以下错误:

javapns.devices.exceptions.InvalidDeviceTokenFormatException: Device Token has a length of [140] and not the required 64 bytes!eror has occusred:Device Token has a length of [140] and not the required 64 bytes!

        at javapns.devices.implementations.basic.BasicDevice.validateTokenFormat(BasicDevice.java:67)
        at javapns.devices.implementations.basic.BasicDevice.<init>(BasicDevice.java:49)
        at javapns.devices.implementations.basic.BasicDevice.<init>(BasicDevice.java:37)

这就是我创建设备列表的方式:
List<Device> newList = new ArrayList<Device>();
            Iterator<String> tempItr = v.iterator();
            while (tempItr.hasNext()) {
                String myDeviceToken = (String) (vItr.next());
                try {
                    BasicDevice device = new BasicDevice(myDeviceToken);

                    newList.add(device);

                } catch (Exception e) { // error=2; // notification issue
                    System.out.println("eror has occusred:" + e.getMessage());
                    e.printStackTrace();

                }
            }

任何提示为何给出无效 token 格式的线索:

最佳答案

这是错误的:

String myDeviceToken = (String) (vItr.next());

它应该是 :
String myDeviceToken = vItr.next().getToken();

编辑:我以为v是List<Device>,但您没有指定v的类型。

关于java - Javapn给InvalidDeviceTokenFormatException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14587496/

10-09 14:51