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
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user
Accepted Solution

BBM App not receiving messages

Greetings.

 

I am developing a chat using the BBM 6.0 (SDK 1.0).

I have encoutered a problem while trying to listen to the sent messages becuase the listeners are not ever been triggered. That provoques that the application be able just to send messages but not to received and show any of them.

 

I know the application is sending the messages based on the fact that invitations are sent and received propperly.

 

This is how I send and listen to the messages:

 

//Suppose this is correctly initialized
// with "session = messagingService.createSession(sessionListener);"
private BBMPlatformSession session;

//This is my session listener
private BBMPlatformSessionListener sessionListener = new BBMPlatformSessionListener() {		
	public void dataReceived(BBMPlatformConnection connection,
			BBMPlatformContact sender, BBMPlatformData data) {		
	}
		
	public void contactsJoined(BBMPlatformConnection connection,
			final BBMPlatformContactList contactList, String cookie, int type) {
		onContactJoined((BBMPlatformContact)contactList.getAll().nextElement());
	}
	
	public void contactsInvited(BBMPlatformConnection connection,
			BBMPlatformContactList contactList) { }
		
	public void contactLeft(BBMPlatformConnection connection,
			BBMPlatformContact contact) { }
		
	public void contactDeclined(BBMPlatformConnection connection,
			BBMPlatformContact contact) { }
		
	public void contactsRemoved(BBMPlatformSession session,
			BBMPlatformContact removedBy, BBMPlatformContactList contactList) { }
		
	public void broadcastDataReceived(BBMPlatformSession session,
			final BBMPlatformContact sender, final BBMPlatformData data) {
		UiApplication.getUiApplication().invokeLater(new Runnable() {				
			public void run() {
				ChatMainScreen.getInstance(ChatAppPlugin.this)
						.showReceivedMessage(data.getDataAsString(), sender.getDisplayName());	
			}
		});
	}
}; 

public void sendMessage(String message) {
	BBMPlatformData data = new BBMPlatformData(message);
	try {
		session.broadcastData(data);
	} catch (final BBMPlatformException e) {
		UiApplication.getUiApplication().invokeLater(new Runnable() {				
			public void run() {
				Dialog.alert(e.getMessage());
			}
		});
	} 
}

 

What I exactly need to know is which is the way I have to do things in order to received and show my messages in the other devices connected to my app.

 

I hope you could help me as soon and accurate as possible.

 

Anticipate thanks.


Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
Developer
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user

Re: BBM App not receiving messages

I have to add that, although the invitation is sent and correctly received, when a contact joins the session the notifying listener never gets triggered.

Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
Developer
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user

Re: BBM App not receiving messages

Greetings again.

I am steal needing any help with this.

Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
Developer
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user

Re: BBM App not receiving messages

Ok, I found the solution.

Thanks for not helping.

Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
Developer
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user

Re: BBM App not receiving messages

Below, an explanation of my problem and my workaround:

 

 

A connection provides communication between several application instances that can be set public or private.

 

According to the BBM documentation, to create a connection you must create a connection listener and use the messaging service to set the listener and retrieve a connection, as follows:

 

MessagingService messagingService = platformContext.getMessagingService();

BBMPlatformSession session = messagingService.createSession(new MySessionListener());

 

/*BBMPlatformSession and BBMPlatformChannel are BBMPlatformConnection childs such as their respective listener share the same relationship.*/

 

The matter with the example above is that the connection is not useful because neither the connection nor the connection listener is related to the messaging service. And that is because the messaging service will be trying to use the connection returned by its messaging service listener which is not the same connection created above.

 

Workaround

 

Create a messaging service listener to obtain the created connection and connection listener, as follows:

 

...

private MessagingService messagingService;

private BBMPlatformSession session;

private BBMPlatformSessionListener sessionListener;

 

...

 

sessionListener = new BBMPlatformSessionListener() {

            ...

};

 

messagingListener = new MessagingServiceListener() {

           

            public void sessionEnded(BBMPlatformContact contact,

                                   BBMPlatformSession session) { }

                                  

            public void sessionCreated(BBMPlatformSession session) {

                        BBMPlugin.this.session = session;

            }          

           

            public BBMPlatformSessionListener getSessionListener(

                                   BBMPlatformSession session) {

                        return sessionListener;

            }          

           

            public BBMPlatformChannelListener getChannelListener(

                                   BBMPlatformChannel channel) {

                        return null;

            }          

            public void channelCreated(BBMPlatformChannel channel, int menuItemId) { }      

            public void channelCreated(BBMPlatformChannel channel) { }

};

 

...

 

...

 

//In the platform context listener

messagingService = platformContext.getMessagingService();

messagingService.setServiceListener(messagingListener);

session = messagingService.createSession(sessionListener);

 

...

...

 

 



Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.
New Contributor
JoseBozzano
Posts: 4
Registered: ‎12-27-2011
My Device: 8900

Re: BBM App not receiving messages

johanguzman07
where put ??

messagingService = platformContext.getMessagingService();
messagingService.setServiceListener(messagingListener);
session = messagingService.createSession(sessionListener);
?
New Contributor
JoseBozzano
Posts: 4
Registered: ‎12-27-2011
My Device: 8900

Re: BBM App not receiving messages

please help me, same problem i have
New Contributor
JoseBozzano
Posts: 4
Registered: ‎12-27-2011
My Device: 8900

Re: BBM App not receiving messages

whats BBMPlugin.this.session = session ???
BBMPlugin ??
Developer
johanguzman07
Posts: 102
Registered: ‎07-26-2011
My Device: Not a blackberry user

Re: BBM App not receiving messages

BBMPlugin is a class of my own. Ignore that, please.

 

Where BBMPlugin.this.session = session, set your BBMPlatformSession object to the BBMPlatformSession you' re using (that's pretty important).


Let me know if this was helpful or if you have a solution.

Johan Guzmán - In case my answer pleased you, give a press to the LIKE button, please!! Mark this post as solution if it solved your problem.