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
Visitor
Posts: 1
Registered: ‎03-08-2012
My Device: torch 9800
My Carrier: Movistar
Accepted Solution

Another application already listening for Application ID throws only on simulator

[ Edited ]

Hi, 

 

I'm testing push notifications in my app using the Push API, targeting to 5.0. I can run the application without problems in a device. But when I try to run the application in the simulator, it only works the first time, if I exit the application and enter again, the method PushApplicationRegistry.registerApplication throws the following exception:

 

Another application already listening for Application ID

 

I know that push notifications don't work in the simulator, but I'm not totally sure that this is an issue of the simulator, seems like every time I launch the application the application descriptor is different.

 

Here is my code for registration:

 

public void notificationsRegister() {
    	ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor();
        byte serverType = PushApplicationDescriptor.SERVER_TYPE_BPAS;

        PushApplicationDescriptor pad = new PushApplicationDescriptor(NOTIFICATION_APP_ID, NOTIFICATION_PORT, NOTIFICATION_URL, serverType, ad);

        // check whether already registered or registration pending
        PushApplicationStatus pushApplicationStatus = PushApplicationRegistry.getStatus( pad );
        byte pasStatus = pushApplicationStatus.getStatus();
		
        if( pasStatus != PushApplicationStatus.STATUS_ACTIVE &&  pasStatus != PushApplicationStatus.STATUS_PENDING) {
            PushApplicationRegistry.registerApplication(pad);
            System.out.println("Registration request sent");
        }
        else {
            System.out.println("Already registered");
        }  	
    }

 

 

I would like to know if this is an issue of the simulator, or maybe I'm doing something wrong.

 

Thanks

 

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: Another application already listening for Application ID throws only on simulator

You should only register your application once, when it is first installed or the device boots up. This port, once registered with your application, is persistently stored in the device.

 

The code below should likely be placed into an Alternate Entry point that only runs on startup.

 

Cheers,

Garett
@garettBeuk
--
Goodbye everybody!
Contributor
Posts: 16
Registered: ‎04-05-2013
My Device: Blackberry 9780
My Carrier: None

Re: Another application already listening for Application ID throws only on simulator

Hi,

 

Sorry, I understand that this is a solved thread. Just one question though.

 

I am developing a cross paltform application using phonegap and Jquery mobile. I am trying to implement push notifications for the blackberry application using PushWosh. 

 

After installing the application, I am able to register properly and receive Push Notifications. But, when I close the application and open it again I get an error which says "Another application already listening for Application ID 27******".

 

Where do i have to place the register method in mu code such that it gets executed only on startup/ first installation ???

 

I am new to WebWorks develoment and can  use all the help...

 

Thanks a million.