1

我正在使用 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();

                }
            }

为什么它给出无效令牌格式的任何线索:

4

1 回答 1

1

This is wrong :

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

It should be :

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

EDIT : I was assuming that v was List<Device>, but you didn't specify the type of v.

于 2013-01-29T16:46:40.317 回答