Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
New Contributor
afterburnerltt
Posts: 2
Registered: ‎01-16-2012
My Device: 9800
My Carrier: Vodacom

Some Device IDs are invalid when using Push

Hi All

 

I've encountered rather a strange issue when using the push APIs.

We have a webserver that pushes out a command to blackberry phones around the world.

I use the following code to send a push to a device:

 

String sendaddress = "<address address-value=\"" + pin + "\"/>";
        StringBuilder data = new StringBuilder();
        data.append("--mPsbVQo0a68eIL3OAxnm\r\n");
        data.append("Content-Type: application/xml; charset=UTF-8\r\n\r\n");
        data.append("<?xml version=\"1.0\"?>\r\n");
        data.append("<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 2.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd\">\r\n");
        data.append("<pap>");
        data.append("<push-message push-id=\"").append(MessageID).append("\" deliver-before-timestamp=\"").append(PushDataTimeoutValue).append("\" source-reference=\"").append(appid).append("\">");
        data.append(sendaddress);
        data.append("<quality-of-service delivery-method=\"unconfirmed\"/>");
        data.append("</push-message>");
        data.append("</pap>\r\n");
        data.append("--mPsbVQo0a68eIL3OAxnm\r\n");
        data.append("Content-Type: text/plain\r\n");
        data.append("Push-Message-ID: ").append(MessageID).append("\r\n\r\n");
        data.append(message).append("\r\n");
        data.append("--mPsbVQo0a68eIL3OAxnm--\r\n");

        // Send data
        URL url = new URL(bpasurl);
        URLConnection conn = url.openConnection();
        conn.addRequestProperty("User-Agent", "BlackBerry Push Service SDK/1.0");
        conn.addRequestProperty("Content-Type", "multipart/related; boundary=mPsbVQo0a68eIL3OAxnm; type=application/xml");
        conn.addRequestProperty("Accept", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
        conn.addRequestProperty("Authorization", "Basic " + encAppIDAndPassword);
        conn.setDoOutput(true);
        conn.setConnectTimeout(5000);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data.toString());
        wr.flush();

 

This works for most devices. The odd thing is that there are some device pins which don't and I receive the following error:

 

<?xml version="1.0"?>
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 2.1//EN" "http://www.openmobilealliance.org/tech/DTD/pap_2.1.dtd"><pap><badmessage-response code="2000" desc="Invalid or missing attribute push-id" bad-message-fragment="Invalid or missing attribute push-id"/></pap>

 

The odd thing is that these devices have valid device IDs as in they are 8 digit hex strings retrieved by using:

 

int pin = DeviceInfo.getDeviceId();
final String PINString = Integer.toHexString(pin);
PushID = PINString.toUpperCase();

 

Some of the devices that do not work are the following:

9650 - Verizon Wireless Running 6.0.0.719 (4.4.0.560)

8530 - Verizon Wireless Running 5.0.0.973 (4.2.0.422)

 

It doesn't seem to be the device model or OS version that causes the issue though I can't be sure about that.

Is it possible that a device must have registered to use Push for BBM or have registered for BIS before their PIN can work? I've tried testing on a device whose BIS access has expired but the issue does not occur.

 

Which leads me to suspect that these users might have never registered for BIS....

Could this be the case?

 

Thanks

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Some Device IDs are invalid when using Push

Users definitely need to subscribe to your application before pushes will work. You can verify a PIN's subscription status by running a subscriptionquery-message request:

http://docs.blackberry.com/tr-tr/developers/deliverables/25167/PAP_ref_subscriptionquery-message_128...

 

If you encounter any further difficulties after verifying this then please post back the full XML (except for the device PIN) that was sent to the push server and resulted in this error.

 

Thanks,

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.