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
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Is it possible ? (BlackBerry Messenger Question)

Is it still possible to create a BBM received listener in an application with the BlackBerry Social Platform SDK ?

 

The Social Platform looks more like a tool developers would use to create their own sessions then they would be able to listen to events within those created sessions. What I believe is the new Social Platform is meant to replace http://www.blackberry.com/developers/docs/7.0.0api/net/rim/blackberry/api/blackberrymessenger/packag... which has been deprecrated since BlackBerry Messenger 5 came out. 

 

Here is what I think would've been a working BBM received listener back in the old API.

 

//Get BlackBerryMessenger instance
BlackBerryMessenger bm = BlackBerryMessenger.getInstance();
bm.addSessionRequestListener(new BlackBerrySessionRequestListener(), ApplicationDescriptor.currentApplicationDescriptor());

 

class BlackBerrySessionRequestListener implements SessionRequestListener
{
public void sessionRequestAccepted(Session session)
{
session.addListener(new BlackBerrySessionListener(), ApplicationDescriptor.currentApplicationDescriptor());
}
}

class BlackBerrySessionListener implements SessionListener
{
public void messageReceived(Session session, Message message)
{
//Message is Received!
//Get UID of the contact that messaged us!
session.getContact().getContactId();
}

//These are not part of my point.
public void sessionClosed(Session session) {}
public void messageDelivered(Session session, Message message) {}
public void messageQueuedForSend(Session session, Message message) {}
public void messageSent(Session session, Message message) {}
}

 

See I want to be able to tell if a message has been received on BlackBerry Messenger, then I want to be able to grab the P.I.N or maybe other unique identifer info from that message received event. 
I do not think the functionality is available on the new BBM SDK and the old one I just linked to of course does not work anymore. Does anyone have any ideas? 

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Is it possible ? (BlackBerry Messenger Question)

Use this listner:

 

private final BBMPlatformChannelListener _channelListener = new BBMPlatformChannelListener() 
{
        public void contactsInvited(BBMPlatformConnection connection, BBMPlatformContactList contactList) 
        {
        	//contactsInvited
        }
        
        public void contactsJoined(BBMPlatformConnection connection, BBMPlatformContactList contactList, final String cookie, int type) 
        {
            BBMPlatformContact contact = (BBMPlatformContact) contactList.getAll().nextElement();
            if (type == CONTACT_INVITING_ME) 
            {
            	
            } 
            else if (type == CONTACT_INVITED_BY_ME) 
            {
            	
            }
        }
        
        public void contactDeclined(BBMPlatformConnection connection, BBMPlatformContact contact) 
        {
        	//contactDeclined
        }
       
        public void contactLeft(BBMPlatformConnection connection, BBMPlatformContact contact) 
        {
            _callback.onContactLeft(contact);
        }
        // someone sent me some data in the channel
        public void dataReceived(BBMPlatformConnection connection, BBMPlatformContact sender, BBMPlatformData data) 
        {
            String msg = data.getDataAsString();
            String type = data.getContentType();
    onMessageReceived(sender, type, msg);//here you call the your own method;
        }
        
        public void joinRequestReceived(BBMPlatformConnection connection, BBMPlatformIncomingJoinRequest request, String param) 
        {
        	request.accept(null);  // automatically accept all public requests            
        }
        
        public void joinRequestCanceled(BBMPlatformConnection connection, BBMPlatformIncomingJoinRequest request, int code) 
        {
        	//joinRequestCanceled
        }
};

 create your own function of  onMessageReceived();

 

 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: Is it possible ? (BlackBerry Messenger Question)

Is there a function I have to use to add that listener? I don't think it'll just work by itself will it ?  

Please use plain text.
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: Is it possible ? (BlackBerry Messenger Question)

Up

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Is it possible ? (BlackBerry Messenger Question)

See first the sample demos provided by BBM Sdk 1.1 or BBM SDK 1.2(Latest) TicTacToe Application. You can understand very well.

When you create your own application, at starting time:

 

BBMPlatformApplication bbmPlatformApplication=new BBMPlatformApplication(UUID);
BBMPlatformContext bbmPlatformContext=BBMPlatformManager.register(bbmPlatformApplication);
bbmPlatformContext.setListener(bbmPlatformContextListener);

 bbmPlatformContextListener is the listener which I provided above. This listner works up to the applicaiton close. whenever any message comes this will invoke.

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: Is it possible ? (BlackBerry Messenger Question)

That won't work with the listener you provided above.

The listener you provided above is a BBMPlatformChannelListener, bbmPlatformContext.setListener requires a BBMPlatformContextListener as the arguement. 

Please use plain text.
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: Is it possible ? (BlackBerry Messenger Question)

up

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is it possible ? (BlackBerry Messenger Question)

[ Edited ]

Sorry only looked very briefly, perhaps misunderstood the questions.

 

AFAIK, in your program you can't get access to standard BBM chat or in fact any communication that is being directed to any other application but your own.  In addition your application can not get hooked in to another application's session or channels.

 

What are you actually trying to do?

Please use plain text.
New Contributor
nightmares18
Posts: 6
Registered: ‎11-27-2011
My Device: Blackberry Torch 9800
My Carrier: Rogers

Re: Is it possible ? (BlackBerry Messenger Question)

@peter_strange Well you see I'm making this app that can make LED flash different colours when you get messages from different people. So I got text messages working fine, users can enter a number and select what colour they want the LED to flash. However, I can't do the same with BBM because I can't listen to BBM messages like I can listen to text messages. 

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: Is it possible ? (BlackBerry Messenger Question)

I see - nice idea.

 

Sorry I am not aware of a way of doing this with BBM.

Please use plain text.