Send a download invitation to a contact

Before you begin: Make sure you have completed the task, Register your application with the BlackBerry Messenger pPlatform, and that the class that displays the MyBBMInviteScreen screen passes in a reference to the application's associated BBMPlatformContext object into the screen's contructor.
  1. Import the required classes and interfaces.
    import net.rim.blackberry.api.bbm.platform.*;
    import net.rim.blackberry.api.bbm.platform.service.*;
    import net.rim.device.api.ui.component.*;
  2. Create a class that extends MainScreen. In the constructor for this screen class, pass in the application's associated BBMPlatformContext.
    public class MyBBMInviteScreen extends MainScreen
    {
        public MyBBMInviteScreen(BBMPlatformContext platformContext)
        {
    
        }
    }
  3. In the constructor, retrieve a reference to the messaging service associated with this application's platform context.
    public class MyBBMInviteScreen extends MainScreen
    {
        public MyBBMInviteScreen(BBMPlatformContext platformContext) 
        {
            MessagingService messagingService = platformContext.getMessagingService();
        }
    }
  4. Invoke MessagingService.sendDownloadInvitation() to invite a contact to download your application. A Contact picker UI component opens for the user to choose a contact to invite.
    public class MyBBMInviteScreen extends MainScreen
    {
        public MyBBMInviteScreen(BBMPlatformContext platformContext) 
        {
            MessagingService messagingService = platformContext.getMessagingService();
            messagingService.sendDownloadInvitation();
        }
    }

Code sample: Sending a download invitation to a contact

The following code sample assumes that the class that displayed the MyBBMInviteScreen has passed a reference to the application's associated BBMPlatformContext object into the MyBBMInviteScreen constructor.

import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.service.*;
import net.rim.device.api.ui.component.*;

public class MyBBMInviteScreen
{
    public MyBBMInviteScreen(BBMPlatformContext platformContext)
    {
        MessagingService messagingService = platformContext.getMessagingService();
        messagingService.sendDownloadInvitation();
    }
}
Back To Top

Was this information helpful? Send us your comments.