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

Java Development

Reply
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone
Accepted Solution

Push Service?

Hi,

 

I am able to register to Push service now want to add unregister from push service, How can this be possible?

 

 

Thanks & Regards

Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Push Service?

I am using this code to unregister : 

public static void unregisterBpas()
{ final String unregisterUrl = formUnRegisterRequest(BPAS_URL, APP_ID, null) + CONNECTION_SUFFIX; LogFile.log(url, "Unregister URL ---> " + unregisterUrl); new Thread() { public void run() { try { HttpConnection httpConnection = (HttpConnection) Connector.open(unregisterUrl); InputStream is = httpConnection.openInputStream(); String response = new String(IOUtilities.streamToBytes(is)); testTokenString = response; close(httpConnection, is, null); String nextUrl = formUnRegisterRequest(BPAS_URL, APP_ID, response) + CONNECTION_SUFFIX; HttpConnection nextHttpConnection = (HttpConnection) Connector.open(nextUrl); InputStream nextInputStream = nextHttpConnection.openInputStream(); response = new String(IOUtilities.streamToBytes(nextInputStream)); LogFile.log(url, "Response ----> " + response); close(nextHttpConnection, is, null); if (DEREGISTER_SUCCESSFUL.equals(response)) { LogFile.log(url, "Unregistered successfully for BIS push"); close(nextHttpConnection, nextInputStream, null); MessageReadingThread.running = false; } else { System.out.println("BPAS rejected unregistration"); LogFile.log(url, "BPAS rejected unregistration"); } } catch (IOException e) { System.out.println("IOException on register() " + e + " " + e.getMessage()); } } }.start(); }

 This code giving me response okay i.e rc = 200, but when i again registered to push service it will failes to receive push messages,

while (running) 
{
      try 
      {
	Object o = socket.acceptAndOpen();
	conn = (HttpServerConnection) o;
	inputStream = conn.openInputStream();
	pushInputStream = new MDSPushInputStream(conn, inputStream);
	PushMessageReader.process(pushInputStream, conn);
      } 
     catch (Exception e) 
     {
	if (running) 
	{
		System.out.println("Failed to read push message, caused by " + e.getMessage());
		running = false;
	}
     } 
     finally 
    {
	close(conn, pushInputStream, null);
    }
}
System.out.println("Stopped listening for push messages");

 It stop listening to push messages when i again register to push service?

Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Push Service?

[ Edited ]

Getting exception null when again going for registeration with push server, Please help me on this?

Please use plain text.
Developer
developer_aman_arora
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Push Service?

done i m not closing socket connection:smileyhappy:
Please use plain text.